【问题标题】:Using Proxy System Wide Ubuntu使用代理系统范围的 Ubuntu
【发布时间】:2014-12-29 13:48:11
【问题描述】:

我正在使用没有 GUI 的无头 ubuntu 系统。我想为我的 ubuntu 使用 pac-based 代理。我也想在 deluge bittorent 客户端上使用它

我目前正在使用此设置

gsettings set org.gnome.system.proxy mode 'manual'
gsettings set org.gnome.system.proxy.http enabled true
gsettings set org.gnome.system.proxy.http host 'http://localhost/proxy.pac'

这是我的 .pac 文件的内容:

function isPlainHostNameEx(host){
  return !(!!~host.indexOf('.') || !!~host.indexOf(':'));
}

function FindProxyForURL(url, host){
  var lhost = host.toLowerCase();
  host = lhost;
  IPNotation = /^\d+\.\d+\.\d+\.\d+$/g;

  var direct = [
    "local", "dev", "ip", "box", "lvh.me", "ripe", "invalid",
    "intra", "intranet", "onion", "vcap.me", "127.0.0.1.xip.io",
    "smackaho.st", "localtest.me", "site", "ip"
  ]
  for(var i=0;i<direct.length;i++){
    if(dnsDomainIs(host, direct[i])){
      return "DIRECT";
    }
  }

  var CC = "DE";
  var exceptions = JSON.parse('[{"CC":"US"}]');

  for(var i=0;i<exceptions.length;i++){
    var e = exceptions[i];
    if(e.CC == CC) {
      for(var j=0;j<e.domains.length;j++){
        if(dnsDomainIs(host, e.domains[j])){
          return e.nodes;
        }
      }
    }
  }

  return "12.024.04.10"
}

当我运行 apt-get update 时,我收到以下错误:

 W: Failed to fetch http://stingray.cyber.net.pk/pub/ubuntu/dists/trusty-proposed/Release.gpg Could not resolve 'stingray.cyber.net.pk' 

我能做些什么来解决这个问题?

【问题讨论】:

标签: javascript ubuntu bittorrent pac


【解决方案1】:

我稍微修正了你的问题,试图让它更清楚。 我承认我从未写过.pac 文件,但在我看来,错误可能与该行有关

return "12.024.04.10"

我没有找到任何关于从 FindProxyForURL 返回直接 IP 地址的文档。也许你的意思是

return "PROXY 12.024.04.10";

另外请检查您的服务器是否可以访问12.024.04.10

最后请注意块代码

for(var i=0;i<exceptions.length;i++){
    var e = exceptions[i];
    if(e.CC == CC) {
      for(var j=0;j<e.domains.length;j++){
        if(dnsDomainIs(host, e.domains[j])){
          return e.nodes;
        }
      }
   }
}

只要CCexceptions 将在您向我们展示的代码中硬定义(分别为"DE"'[{"CC":"US"}]'),就永远不会返回任何内容,但如果您要更改这两者变量请检查return e.nodes; 是否也会返回一个有效的字符串(又名"PROXY &lt;some_ip&gt;:&lt;some_port&gt;")。

希望对你有帮助:)

【讨论】:

  • pac 文件很好我编辑了一些 pac 文件以保存一些代理服务器(在那个过程中我可能已经更改了一些代码)。我可以在我的机器上使用 foxy 代理来使用它,但我如何在无头机器上使用它。
  • 对不起,我很难理解你在问什么,可能是因为我不是这个领域的专家,但我建议你检查一下这个问题的答案:@987654321 @ 最后是本指南:help.ubuntu.com/community/AptGet/…
猜你喜欢
  • 1970-01-01
  • 2013-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多