diff --git a/README.md b/README.md index 12bf6e9..f5aba68 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ PAC scripts for proxies - `pac-.txt` 包含从数据源 `` 获取的 IP 地址列表(白名单) - `pad-gfwlist-.txt` 在 IP 白名单的基础上添加了 GFWList 的匹配 -本代码是为 Shadowsocks Windows 4.1.9 及以上版本设计的,若要在旧版本中使用(或使用其他代理软件)请手动修改代码第 4 行 `__PROXY__` 为你的代理地址,详情见 [shadowsocks-windows#2761](https://github.com/shadowsocks/shadowsocks-windows/issues/2761)。 +本代码是为 Shadowsocks Windows 4.1.9 及以上版本设计的,若要在旧版本或使用其他代理软件中使用,请手动修改文件第 5 行 `__PROXY__` 为你的代理地址,详情见 [shadowsocks-windows#2761](https://github.com/shadowsocks/shadowsocks-windows/issues/2761)。 ## 贡献 diff --git a/code.js b/code.js index 817b525..1f4b0e0 100644 --- a/code.js +++ b/code.js @@ -1,14 +1,14 @@ -// Author: iBug +// Author: iBug +// Source: https://github.com/iBug/pac // Time: @@TIME@@ var proxy = __PROXY__; var direct = "DIRECT"; function belongsToSubnet(host, list) { - var ip = host.split(".").map(Number); - ip = 0x1000000 * ip[0] + 0x10000 * ip[1] + 0x100 * ip[2] + ip[3]; + var ip = convert_addr(host) >>> 0; - if (ip < list[0][0]) + if (list.length === 0 || ip < list[0][0]) return false; // Binary search @@ -23,7 +23,7 @@ function belongsToSubnet(host, list) { // Match var masked = ip & list[x][1]; - return (masked ^ list[x][0]) == 0; + return (masked ^ list[x][0]) === 0; } function hasMatchedPattern(text, patterns) {