runet-censorship-bypass/pac-generator/src/blocked-hosts-plain-switch.js
Ilya Ig. Petrov 00d23d0292 refactored
2015-11-28 14:20:45 +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' );
}