Run PAC file in specific context.
Assume a PAC "template" file template.pac
, some variable is replaced to real value on server side. (So it can't directly run in JS engine):
// template.pac
// _HOST and _PROXY will replaced with real value before send to client.
function FindProxyForURL(url, host) {
if (host == _HOST) return _PROXY;
return 'DIRECT;';
}
import { PAC } from 'pacrunner';
console.log(
PAC.FromFile('template.pac').Run('https://exhentai.org/img/kokomade.jpg', {
_HOST: 'exhentai.org',
_PROXY: 'SOCKS 127.0.0.1:1080;'
})
);
// console: 'SOCKS 127.0.0.1:1080;'