首页 > 解决方案 > pac 文件 SyntaxError: Unexpected number 问题

问题描述

如果目标主机名是本地的,我正在尝试制作一个 PAC 文件来引导用户绕过代理,如果目标主机名是公共的,它将为 2 个代理分配流量。如果 2 个代理出现故障,它将直接绕过代理。它给了我 SyntaxError: Unexpected number 但我找不到任何语法错误。

 function FindProxyForURL(url, host) {
 

    //if local domains match return direct 
    if (isInNet(host, "172.16.0.0", "255.240.0.0") || isInNet(host, "192.168.0.0", "255.255.255.0" ) || isInNet(host, "10.0.0.0", "255.0.0.0") )
          {          
          return "DIRECT";  
          }else {
              
                  // Find the 4th octet
                   var myip=myIpAddress()
                   var ipbits=myip.split(".")
                   var myseg=parseInt(ipbits[3])

                  // Check to see if the 4th octect is even or odd
                  if (myseg==Math.floor(myseg/2)2) {
                  // Even
                  proxy = "PROXY p1.company.com:8080; PROXY p2.company.com:8080 DIRECT";
                  }
                  else {
                  // Odd
                  proxy = "PROXY p2.company.com:8080; PROXY p1.company.com:8080 DIRECT";
                  }
              }   
 }

标签: javascript

解决方案


推荐阅读