41 | 41 |
autoDetect = ieCfg.fAutoDetect
|
42 | 42 |
}
|
43 | 43 |
|
44 | |
// Try WinHTTP default proxy.
|
45 | |
if defaultCfg, err := getDefaultProxyConfiguration(); err == nil {
|
46 | |
defer globalFreeWrapper(defaultCfg.lpszProxy)
|
47 | |
defer globalFreeWrapper(defaultCfg.lpszProxyBypass)
|
48 | |
|
49 | |
newProxy := StringFromUTF16Ptr(defaultCfg.lpszProxy)
|
50 | |
if proxy == "" {
|
51 | |
proxy = newProxy
|
52 | |
}
|
53 | |
|
54 | |
newProxyByPass := StringFromUTF16Ptr(defaultCfg.lpszProxyBypass)
|
55 | |
if proxyByPass == "" {
|
56 | |
proxyByPass = newProxyByPass
|
|
44 |
if proxy == "" && !autoDetect{
|
|
45 |
// Try WinHTTP default proxy.
|
|
46 |
if defaultCfg, err := getDefaultProxyConfiguration(); err == nil {
|
|
47 |
defer globalFreeWrapper(defaultCfg.lpszProxy)
|
|
48 |
defer globalFreeWrapper(defaultCfg.lpszProxyBypass)
|
|
49 |
|
|
50 |
// Always set both of these (they are a pair, it doesn't make sense to set one here and keep the value of the other from above)
|
|
51 |
proxy = StringFromUTF16Ptr(defaultCfg.lpszProxy)
|
|
52 |
proxyByPass = StringFromUTF16Ptr(defaultCfg.lpszProxyBypass)
|
57 | 53 |
}
|
58 | 54 |
}
|
59 | 55 |
|
|
167 | 163 |
}
|
168 | 164 |
|
169 | 165 |
func readRegedit() (values regeditValues, err error) {
|
170 | |
k, err := registry.OpenKey(registry.CURRENT_USER, `Software\Microsoft\Windows\CurrentVersion\Internet Settings`, registry.QUERY_VALUE)
|
|
166 |
var proxySettingsPerUser uint64 = 1 // 1 is the default value to consider current user
|
|
167 |
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings`, registry.QUERY_VALUE)
|
|
168 |
if err == nil {
|
|
169 |
//We had used the below variable tempPrxUsrSettings, because the Golang method GetIntegerValue
|
|
170 |
//sets the value to zero even it fails.
|
|
171 |
tempPrxUsrSettings, _, err := k.GetIntegerValue("ProxySettingsPerUser")
|
|
172 |
if err == nil {
|
|
173 |
//consider the value of tempPrxUsrSettings if it is a success
|
|
174 |
proxySettingsPerUser = tempPrxUsrSettings
|
|
175 |
}
|
|
176 |
k.Close()
|
|
177 |
}
|
|
178 |
|
|
179 |
var hkey registry.Key
|
|
180 |
if proxySettingsPerUser == 0 {
|
|
181 |
hkey = registry.LOCAL_MACHINE
|
|
182 |
} else {
|
|
183 |
hkey = registry.CURRENT_USER
|
|
184 |
}
|
|
185 |
|
|
186 |
k, err = registry.OpenKey(hkey, `Software\Microsoft\Windows\CurrentVersion\Internet Settings`, registry.QUERY_VALUE)
|
171 | 187 |
if err != nil {
|
172 | 188 |
return
|
173 | 189 |
}
|