Javascript 使用代理系统范围的Ubuntu

Javascript 使用代理系统范围的Ubuntu,javascript,ubuntu,bittorrent,pac,Javascript,Ubuntu,Bittorrent,Pac,我使用的是一个没有GUI的无头ubuntu系统。我想为我的ubuntu使用一个代理。我还想在Bullge 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://localhos

我使用的是一个没有GUI的无头ubuntu系统。我想为我的ubuntu使用一个代理。我还想在Bullge 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'
这是my.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"
}

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

我修正了一点你的问题,试图让它更清楚。 我承认我从来没有写过
.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;
        }
      }
   }
}

for(var i=0;i问题是什么?:/这是我想用于无头服务器的pac脚本。当我运行apt get update时,我收到以下错误W:无法获取无法解析“stingray.cyber.net.pk”pac文件很好我编辑了一些pac文件以保存一些代理服务器(在该过程中,我可能更改了一些代码)。我可以在我的机器上使用foxy proxy,但如何在无头机器上使用它。很抱歉,我很难理解您的问题,可能是因为我不是该领域的专家,但我可以建议您检查这个问题的答案吗:最终,本指南:
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;
        }
      }
   }
}