1# ieproxy
2
3Go package to detect the proxy settings on Windows platform.
4
5The settings are initially attempted to be read from the [`WinHttpGetIEProxyConfigForCurrentUser` DLL call](https://docs.microsoft.com/en-us/windows/desktop/api/winhttp/nf-winhttp-winhttpgetieproxyconfigforcurrentuser), but falls back to the registry (`CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings`) in the event the DLL call fails.
6
7For more information, take a look at the [documentation](https://godoc.org/github.com/mattn/go-ieproxy)
8
9## Methods
10
11You can either obtain a `net/http` compatible proxy function using `ieproxy.GetProxyFunc()`, set environment variables using `ieproxy.OverrideEnvWithStaticProxy()` (though no automatic configuration is available this way), or obtain the proxy settings via `ieproxy.GetConf()`.
12
13| Method                                 | Supported configuration options:              |
14|----------------------------------------|-----------------------------------------------|
15| `ieproxy.GetProxyFunc()`               | Static, Specified script, and fully automatic |
16| `ieproxy.OverrideEnvWithStaticProxy()` | Static                                        |
17| `ieproxy.GetConf()`                    | Depends on how you use it                     |
18
19## Examples
20
21### Using GetProxyFunc():
22
23```go
24func init() {
25	http.DefaultTransport.(*http.Transport).Proxy = ieproxy.GetProxyFunc()
26}
27```
28
29GetProxyFunc acts as a middleman between `net/http` and `mattn/go-ieproxy` in order to select the correct proxy configuration based off the details supplied in the config.
30
31### Using OverrideEnvWithStaticProxy():
32
33```go
34func init() {
35	ieproxy.OverrideEnvWithStaticProxy()
36	http.DefaultTransport.(*http.Transport).Proxy = http.ProxyFromEnvironment
37}
38```
39
40OverrideEnvWithStaticProxy overrides the relevant environment variables (`HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`) with the **static, manually configured** proxy details typically found in the registry.
41
42### Using GetConf():
43
44```go
45func main() {
46	conf := ieproxy.GetConf()
47	//Handle proxies how you want to.
48}
49```
50