Exclude reserved subnets from replaceDirectWith

This commit is contained in:
ilyaigpetrov 2019-09-28 14:18:50 +00:00
parent 12db4afe55
commit bf70de3727

View File

@ -479,6 +479,32 @@ ${
: `
/******/ const oldTmp = tmp;
/******/ tmp = function(url, host) {
/******/ const ip = dnsResolve(host);
/******/ if (ip) {
/******/ const ipInt = convert_addr(ip);
/******/ if([
/******/ /* Reserved networks: https://en.wikipedia.org/wiki/Reserved_IP_addresses#IPv4 */
/******/ [-16777216, 0 ], // ['0.0.0.0' , '255.0.0.0' ],
/******/ [-16777216, 167772160 ], // ['10.0.0.0' , '255.0.0.0' ],
/******/ [-4194304, 1681915904 ], // ['100.64.0.0' , '255.192.0.0'],
/******/ [-16777216, 2130706432 ], // ['127.0.0.0' , '255.0.0.0' ],
/******/ [-65536, -1442971648], // ['169.254.0.0', '255.255.0.0'],
/******/ [-1048576, -1408237568], // ['172.16.0.0', '255.240.0.0'],
/******/ [-256, -1073741824], // ['192.0.0.0' , '255.255.255.0'],
/******/ [-256, -1073741312], // ['192.0.2.0' , '255.255.255.0'],
/******/ [-256, -1067949312], // ['192.88.99.0' , '255.255.255.0'],
/******/ [-65536, -1062731776], // ['192.168.0.0', '255.255.0.0'],
/******/ [-131072, -971898880 ], // ['198.18.0.0', '255.254.0.0'],
/******/ [-256, -969710592 ], // ['198.51.100.0', '255.255.255.0'],
/******/ [-256, -889163520 ], // ['203.0.113.0', '255.255.255.0'],
/******/ [-268435456, -536870912 ], // ['224.0.0.0', '240.0.0.0'],
/******/ [-268435456, -268435456 ], // ['240.0.0.0', '240.0.0.0'],
/******/ [-1, -1 ], // ['255.255.255.255' , '255.255.255.255'],
/******/ ].some(([netMask, maskedNet]) => (ipInt & netMask) === maskedNet)
/******/ ) {
/******/ return "DIRECT";
/******/ }
/******/ }
/******/ return oldTmp.call(this, url, host).replace(/(;|^)\\s*DIRECT\\s*(?=;|$)/g, "$1${pacMods.replaceDirectWith}");
/******/ };
`