【问题标题】:Chrome extensions - bypass proxy programmaticallyChrome 扩展程序 - 以编程方式绕过代理
【发布时间】:2017-05-10 23:42:35
【问题描述】:

我正在开发一个扩展,其中代理是通过我的扩展使用 chrome 扩展代理 api(chrome.proxy.settings) 设置的。一切正常,我的代理服务器上的所有流量当然除了bypass list 中的流量。

现在我的问题是:How do we bypass the proxy set dynamically? 我的意思是有没有办法以编程方式绕过某些 URL 的代理(不在代理绕过列表中)?我了解绕过列表包含的 url/模式被绕过。但我需要一些 url 来绕过代理。

有人遇到过类似的要求吗?任何动态绕过相同的直接方法或任何解决方法都将不胜感激。

【问题讨论】:

  • 您可能想检查Debugging problems with the network proxy 看看它是否有帮助。如果您不想使用它,它提到了覆盖系统代理设置的给定选项。除此之外,还可以在Proxy settings and fallback找到更多信息。
  • 感谢@Teyam。让我看看这些。
  • 我浏览了这些链接,但它们似乎对我没有帮助。

标签: google-chrome google-chrome-extension proxy google-chrome-os chromebook


【解决方案1】:

在旅途中绕过代理? 您可以从 Web 服务器中提取任何指定的地址。有什么问题?

例如:

chrome.windows.onCreated.addListener(function() {
  var config = {
      mode: 'fixed_servers',
      rules: {
        proxyForHttp: {
          scheme: 'http',
          host: '127.0.0.1',
          port: '80'
        },
        bypassList: []
      }
    },
    proxyByUrl = 'path/to/proxiesByUrl?path=' + window.location.href;

  $.get(proxyByUrl, function(data) {
    // Set up current proxy, dependent on request URL
    config.rules.proxyForHttp.host = data.proxyAddress;
    config.rules.proxyForHttp.port = data.proxyport;
    // Excluded URL's for this proxy
    bypassList.push(data.bypassUrls);
  });
});

匹配所有匹配模式的主机名。一个领先的“。”被解释为“*.”。 示例:“foobar.com”、“foobar.com”、“.foobar.com”、“foobar.com:99”、“https://x..y .com:99"。

有关 bypassList 的更详细模式,read the official documentation

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-30
    • 1970-01-01
    • 2011-10-11
    • 1970-01-01
    • 2015-03-25
    • 2015-03-19
    相关资源
    最近更新 更多