V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
rungo
V2EX  ›  Safari

请问这个 pac 文件哪里有问题?

  •  
  •   rungo · 2016-04-04 14:35:20 +08:00 · 1822 次点击
    这是一个创建于 2915 天前的主题,其中的信息可能已经有所发展或是发生改变。

    代理总是失败

    function FindProxyForURL( url, host )
    {
        url = url.toLowerCase();
        host = host.toLowerCase();
        if ( shExpMatch(url, "*.getlantern.org") || host == "getlantern.org"
    		|| shExpMatch(url, "*.getpocket.com") || host == "getpocket.com"
    		|| shExpMatch(url, "*.ggpht.com") || host == "ggpht.com"
    		|| shExpMatch(url, "*.github.com") || host == "github.com"
    		|| shExpMatch(url, "*.github.io") || host == "github.io"
    		|| shExpMatch(url, "*.githubusercontent.com") || host == "githubusercontent.com"
    		|| shExpMatch(url, "*.gitlab.com") || host == "gitlab.com"
    		|| shExpMatch(url, "*.gmail.com") || host == "gmail.com"
    		|| shExpMatch(url, "*.goo.gl") || host == "goo.gl"
    		|| shExpMatch(url, "*.google-analytics.com") || host == "google-analytics.com"
    		|| shExpMatch(url, "*.google.com") || host == "google.com"
    		|| shExpMatch(url, "*.googleapis.com") || host == "googleapis.com"
    		|| shExpMatch(url, "*.googlesyndication.com") || host == "googlesyndication.com"
    		|| shExpMatch(url, "*.googleusercontent.com") || host == "googleusercontent.com"
    		|| shExpMatch(url, "*.googlevideo.com") || host == "googlevideo.com" )
        {
            return "SOCKS5 127.0.0.1:8016";
        }
        else
        {
            return "DIRECT";
        }
    }
    
    5 条回复    2016-04-04 18:17:38 +08:00
    SoloCompany
        1
    SoloCompany  
       2016-04-04 15:45:57 +08:00
    为啥用 shExpMatch
    正则语法不是像你这样的,你那个叫 glob pattern
    直接用 host.endsWith 呗
    啥? js 没有这个函数? 那就写一个呗
    rungo
        2
    rungo  
    OP
       2016-04-04 17:28:34 +08:00
    @SoloCompany shExpMatch 不是用的正则表达四,是 shell expression,就是通配符,这一点没问题
    rungo
        3
    rungo  
    OP
       2016-04-04 18:16:27 +08:00
    找到原因了, pac 写的没问题,只是我用 shadowsocks 搭的代理应该把` return "SOCKS5 127.0.0.1:8016";` 改成 ` return "SOCKS5 127.0.0.1:8016; SOCKS 127.0.0.1:8016";`
    rungo
        4
    rungo  
    OP
       2016-04-04 18:17:13 +08:00
    找到原因了, pac 写的没问题,只是我用 shadowsocks 搭的代理应该把
    ```
    return "SOCKS5 127.0.0.1:8016";
    ```
    改成
    ```
    return "SOCKS5 127.0.0.1:8016; SOCKS 127.0.0.1:8016";
    ```
    rungo
        5
    rungo  
    OP
       2016-04-04 18:17:38 +08:00
    找到原因了, pac 写的没问题,只是我用 shadowsocks 搭的代理应该把
    ``` return "SOCKS5 127.0.0.1:8016";
    ```
    改成
    ```return "SOCKS5 127.0.0.1:8016; SOCKS 127.0.0.1:8016";
    ```
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   972 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 20:46 · PVG 04:46 · LAX 13:46 · JFK 16:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.