FromURL returns a Dialer given a URL specification and an underlying Dialer for it to make network requests.
(u *url.URL, forward proxy_Dialer)
| 212 | // FromURL returns a Dialer given a URL specification and an underlying |
| 213 | // Dialer for it to make network requests. |
| 214 | func 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 | |
| 240 | var ( |
| 241 | proxy_allProxyEnv = &proxy_envOnce{ |
no test coverage detected