【问题标题】:Use Internet explorer proxy settings使用 Internet Explorer 代理设置
【发布时间】:2017-01-20 13:15:45
【问题描述】:

我正在开发一个需要连接到互联网的 go 应用程序。我使用http.ProxyFromEnvironment 传输在 linux 上自动检测代理,但它在 windows 上不足。

如何检索 Internet Explorer 的代理设置?

【问题讨论】:

    标签: go proxy


    【解决方案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
    }
    

    【讨论】:

    • 这仍然是 2019 年推荐的解决方案,还是现在有一些开箱即用的支持?
    猜你喜欢
    • 2012-02-07
    • 1970-01-01
    • 2010-11-12
    • 1970-01-01
    • 2013-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多