使用代理系统宽Ubuntu

时间:2014-12-29 13:48:12

标签: javascript ubuntu bittorrent pac

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

我目前正在使用此设置

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' 

我该怎么做才能解决这个问题?

1 个答案:

答案 0 :(得分:0)

我解决了一些你的问题,试图让它更清晰。 我承认我从未写过.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 <some_ip>:<some_port>")。

希望它有所帮助:)

相关问题