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

2016-04-04 14:35:20 +08:00
 rungo

代理总是失败

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";
    }
}
1859 次点击
所在节点    Safari
5 条回复
SoloCompany
2016-04-04 15:45:57 +08:00
为啥用 shExpMatch
正则语法不是像你这样的,你那个叫 glob pattern
直接用 host.endsWith 呗
啥? js 没有这个函数? 那就写一个呗
rungo
2016-04-04 17:28:34 +08:00
@SoloCompany shExpMatch 不是用的正则表达四,是 shell expression,就是通配符,这一点没问题
rungo
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
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
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";
```

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/268465

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX