var proxy = __PROXY__; var direct = 'DIRECT'; var directDomains = __DIRECT_DOMAINS__; var domainsUsingProxy = __DOMAINS__; var localTlds = __LOCAL_TLDS__; var cidrs = __CIDRS__; var hasOwnProperty = Object.hasOwnProperty; function isIpAddress(ip) { return /^\d{1,3}(\.\d{1,3}){3}$/.test(ip) || /^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$/.test(ip); } function RadixTree() { this.root = {}; } RadixTree.prototype.insert = function(string) { var node = this.root; for (var i = 0; i < string.length; i++) { var char = string[i]; if (!node[char]) { node[char] = {}; } node = node[char]; } }; RadixTree.prototype.to_list = function() { return this.root; }; function ipToBinary(ip) { // Check if it's IPv4 if (/^\d{1,3}(\.\d{1,3}){3}$/.test(ip)) { return ip.split('.').map(function(num) { return ("00000000" + parseInt(num, 10).toString(2)).slice(-8); }).join(''); } else if (/^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$/.test(ip)) { // Expand the IPv6 address if it contains '::' var parts = ip.split('::'); var left = parts[0] ? parts[0].split(':') : []; var right = parts[1] ? parts[1].split(':') : []; // Calculate the number of zero groups to insert var zeroGroups = 8 - (left.length + right.length); // Create the full address by inserting zero groups var fullAddress = left.concat(Array(zeroGroups + 1).join('0').split('')).concat(right); // Convert each group to binary and pad to 16 bits return fullAddress.map(function(group) { return ("0000000000000000" + parseInt(group || '0', 16).toString(2)).slice(-16); }).join(''); } } function searchRadixTree(bits) { var currentNode = radixTree; var isLastNode = false; for (var i=0; i ' + ip + '] ' + msg); } catch (e) { allowAlert = false } } var radixTree = new RadixTree(); (function () { var startTime = new Date().getMilliseconds(); debug('开始生成 Radix Tree', 'PAC文件载入开始', startTime.toString()); for (let i=0; i