FromEnvironmentUsing returns the dialer specify by the proxy-related variables in the environment and makes underlying connections using the provided forwarding Dialer (for instance, a *net.Dialer with desired configuration).
(forward Dialer)
| 38 | // using the provided forwarding Dialer (for instance, a *net.Dialer |
| 39 | // with desired configuration). |
| 40 | func FromEnvironmentUsing(forward Dialer) Dialer { |
| 41 | allProxy := allProxyEnv.Get() |
| 42 | if len(allProxy) == 0 { |
| 43 | return forward |
| 44 | } |
| 45 | |
| 46 | proxyURL, err := url.Parse(allProxy) |
| 47 | if err != nil { |
| 48 | return forward |
| 49 | } |
| 50 | proxy, err := FromURL(proxyURL, forward) |
| 51 | if err != nil { |
| 52 | return forward |
| 53 | } |
| 54 | |
| 55 | noProxy := noProxyEnv.Get() |
| 56 | if len(noProxy) == 0 { |
| 57 | return proxy |
| 58 | } |
| 59 | |
| 60 | perHost := NewPerHost(proxy, forward) |
| 61 | perHost.AddFromString(noProxy) |
| 62 | return perHost |
| 63 | } |
| 64 | |
| 65 | // proxySchemes is a map from URL schemes to a function that creates a Dialer |
| 66 | // from a URL with such a scheme. |
searching dependent graphs…