mirror of
https://github.com/iBug/pac.git
synced 2025-07-13 12:52:15 +08:00
Use convert_addr for PAC
https://developer.mozilla.org/en-US/docs/Web/HTTP/Proxy_servers_and_tunneling/Proxy_Auto-Configuration_(PAC)_file#convert_addr
This commit is contained in:
parent
3707d2fca0
commit
4dccc7a535
@ -17,7 +17,7 @@ PAC scripts for proxies
|
||||
- `pac-<name>.txt` 包含从数据源 `<name>` 获取的 IP 地址列表(白名单)
|
||||
- `pad-gfwlist-<name>.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)。
|
||||
|
||||
## 贡献
|
||||
|
||||
|
10
code.js
10
code.js
@ -1,14 +1,14 @@
|
||||
// Author: iBug <ibugone.com>
|
||||
// Author: iBug <ibug.io>
|
||||
// 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) {
|
||||
|
Loading…
Reference in New Issue
Block a user