英文:
Use Internet explorer proxy settings
问题
我正在开发一个需要连接到互联网的Go应用程序。我使用http.ProxyFromEnvironment
传输方式来自动检测Linux上的代理,但在Windows上效果不佳。
我该如何获取Internet Explorer的代理设置?
英文:
I'm developing a go application that need to connect to the internet. I use the http.ProxyFromEnvironment
transport to auto-detect the proxy on linux, but it falls short on windows.
How can I retrieve the proxy settings of Internet Explorer?
答案1
得分: 1
这些值可以在注册表中找到:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
。
这是一个简单的库,可以方便地检索这些设置(免责声明:最近我重新编写了这个库):https://godoc.org/github.com/mattn/go-ieproxy
你可以在init
函数中调用OverrideEnvWithStaticProxy()
,以便透明地使用http.ProxyFromEnvironment
:
func init() {
ieproxy.OverrideEnvWithStaticProxy()
http.DefaultTransport.(*http.Transport).Proxy = http.ProxyFromEnvironment
}
英文:
Those values can be found in the registry: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
.
Here is a simple library that allows you to retrieve those settings easily (disclaimer: I re-wrote most of this library recently): https://godoc.org/github.com/mattn/go-ieproxy
You can transparently use http.ProxyFromEnvironment
by calling OverrideEnvWithStaticProxy()
in an init
function:
func init() {
ieproxy.OverrideEnvWithStaticProxy()
http.DefaultTransport.(*http.Transport).Proxy = http.ProxyFromEnvironment
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论