Skip to content

Commit 73fa920

Browse files
πŸ”€ Merge pull request #3008 from shadowsocks/pac-private-ip
πŸŽƒ PAC: workaround to exempt private IP ranges in whitelist mode
2 parents b2b19fe + 701032b commit 73fa920

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

β€Žshadowsocks-csharp/Data/abp.jsβ€Ž

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,22 @@ for (var i = 0; i < rules.length; i++) {
793793
defaultMatcher.add(Filter.fromText(rules[i]));
794794
}
795795

796+
// PAC has no v6 support, it sucks
797+
var ip4Re = /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/
798+
799+
var privateNet = [
800+
["10.0.0.0", "255.0.0.0"],
801+
["127.0.0.0", "255.0.0.0"],
802+
["172.16.0.0", "255.240.0.0"],
803+
["192.168.0.0", "255.255.0.0"],
804+
]
805+
796806
function FindProxyForURL(url, host) {
807+
if (host.match(ip4Re)) {
808+
for (var i = 0; i < privateNet.length; i++) {
809+
if (isInNet(host, privateNet[i][0], privateNet[i][1])) return direct;
810+
}
811+
}
797812
if (userrulesMatcher.matchesAny(url, host) instanceof BlockingFilter) {
798813
return proxy;
799814
}

0 commit comments

Comments
Β (0)