Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ipac

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipac - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

cn.apnic

8

dist/bin/tpl.js

@@ -30,3 +30,3 @@ #!/usr/bin/env node

iplast = all.toString().split(/\n+/g).reduce((function(iplast, ln) {
var ip, ipcnt, ipend, ipstart, vals;
var ip, ipcnt, ipnext, ipstart, vals;
if (!ln) {

@@ -45,8 +45,8 @@ return iplast;

}
ipend = ipstart + ipcnt - 1;
if (iplast + 1 < ipstart) {
ipnext = ipstart + ipcnt;
if (iplast < ipstart) {
ipranges.push(iplast);
ipranges.push(ipstart);
}
return ipend;
return ipnext;
}), 0);

@@ -53,0 +53,0 @@ ipranges.push(iplast);

@@ -1,1 +0,1 @@

global.DEFAULT_TPL = 'var proxy = "PROXY {{proxy_server}}; DIRECT;";\nvar direct = "DIRECT;";\nvar cnIps = [{{cn_ip_ranges}}];\nvar bases = [16777216,65536,256,1];\nfunction ip2int(ip) {\n return ip.split(/\\./g).reduce(function(v, seg, idx) {\n return v + parseInt(seg) * bases[idx];\n }, 0);\n}\nfunction detect(ip) {\n aIp = ip2int(ip);\n var l=0, r=cnIps.length;\n while(l+1<r) {\n m = Math.floor((l + r) / 2);\n mIp = cnIps[m];\n if(aIp < mIp) {\n r = m;\n } else if(aIp == mIp) {\n l = m;\n break;\n } else {\n l = m;\n }\n }\n if(l&1) return true;\n return false;\n}\nfunction FindProxyForURL(url, host) {\n if (!isResolvable(host)) \n return proxy;\n var is = detect(dnsResolve(host));\n if(is) return direct;\n return proxy;\n}';
global.DEFAULT_TPL = 'var proxy = \'PROXY {{proxy_server}}; DIRECT;\';\nvar direct = \'DIRECT;\';\nvar localIps = [167772160,184549376,2851995648,2852061184,2886729728,2887778304,3232235520,3232301056,4026531840,4194304000];\nvar cnIps = [{{cn_ip_ranges}}];\nvar bases = [16777216,65536,256,1];\nfunction ip2int(ip) {\n return ip.split(\'.\').reduce(function(v, seg, idx) {\n return v + parseInt(seg) * bases[idx];\n }, 0);\n}\nfunction detectLocal(ip) {\n aIp = ip2int(ip);\n for(var i=0; i<4; ++i) {\n var lo = localIps[2*i];\n var hi = localIps[2*i+1];\n if (aIp >= lo && aIp < hi)\n return true;\n }\n return false\n}\nfunction detectCN(ip) {\n aIp = ip2int(ip);\n var l=0, r=cnIps.length;\n while(l+1<r) {\n m = Math.floor((l + r) / 2);\n mIp = cnIps[m];\n if(aIp < mIp) {\n r = m;\n } else if(aIp == mIp) {\n l = m;\n break;\n } else {\n l = m;\n }\n }\n if(l&1) return true;\n return false;\n}\nfunction FindProxyForURL(url, host) {\n if (isPlainHostName(host))\n return direct;\n if (!isResolvable(host))\n return direct;\n var ip = dnsResolve(host);\n if (detectLocal(ip))\n return direct;\n if (detectCN(ip))\n return direct;\n return proxy;\n}';
{
"name": "ipac",
"version": "1.0.1",
"version": "1.0.2",
"description": "生成根据 IP 自动选择代理的 PAC 文件",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc