MCPcopy
hub / github.com/gorilla/websocket / proxy_FromURL

Function proxy_FromURL

x_net_proxy.go:214–238  ·  view source on GitHub ↗

FromURL returns a Dialer given a URL specification and an underlying Dialer for it to make network requests.

(u *url.URL, forward proxy_Dialer)

Source from the content-addressed store, hash-verified

212// FromURL returns a Dialer given a URL specification and an underlying
213// Dialer for it to make network requests.
214func proxy_FromURL(u *url.URL, forward proxy_Dialer) (proxy_Dialer, error) {
215 var auth *proxy_Auth
216 if u.User != nil {
217 auth = new(proxy_Auth)
218 auth.User = u.User.Username()
219 if p, ok := u.User.Password(); ok {
220 auth.Password = p
221 }
222 }
223
224 switch u.Scheme {
225 case "socks5":
226 return proxy_SOCKS5("tcp", u.Host, auth, forward)
227 }
228
229 // If the scheme doesn't match any of the built-in schemes, see if it
230 // was registered by another package.
231 if proxy_proxySchemes != nil {
232 if f, ok := proxy_proxySchemes[u.Scheme]; ok {
233 return f(u, forward)
234 }
235 }
236
237 return nil, errors.New("proxy: unknown scheme: " + u.Scheme)
238}
239
240var (
241 proxy_allProxyEnv = &proxy_envOnce{

Callers 2

proxy_FromEnvironmentFunction · 0.85
DialContextMethod · 0.85

Calls 1

proxy_SOCKS5Function · 0.85

Tested by

no test coverage detected