runet-censorship-bypass/pac-generator/src/blocked-hosts-plain-switch.js
2016-05-08 21:14:08 +05:00

28 lines
641 B
JavaScript
Executable File

'use strict';
module.exports = (hosts, ips, generator, generatePac) => {
function ifProxyByPlainSwitch(host) {
function ifBlocked(host) {
switch( host ) {
//CASES
}
return false;
}
var doms = host.split('.');
for( var endi = doms.length-1; endi >= 0; --endi )
if (ifBlocked( doms.slice( endi ).join('.') ))
return true;
return false;
}
var cases = hosts.map( host => 'case "'+host+'":' ).join('\n') +'\nreturn true;';
var ifProxyString = ifProxyByPlainSwitch.toString().replace('//CASES', cases);
return generatePac( ifProxyString, 'host' );
}