https://github.com/shadowsocks/pacrunner
https://github.com/shadowsocks/pacrunner
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/shadowsocks/pacrunner
- Owner: shadowsocks
- License: 0bsd
- Fork: true (komsomolskinari/pacrunner)
- Created: 2019-11-06T12:42:51.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-02T07:32:03.000Z (over 6 years ago)
- Last Synced: 2024-12-08T01:01:23.017Z (over 1 year ago)
- Size: 27.3 KB
- Stars: 5
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
README
# PACRunner
[](https://travis-ci.org/komsomolskinari/pacrunner)
[](https://coveralls.io/github/komsomolskinari/pacrunner?branch=master)
[](https://badge.fury.io/js/pacrunner)
Run PAC file in specific context.
## Example
[Demo project](https://github.com/komsomolskinari/pacrunner-demo/)
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):
```js
// 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;';
}
```
```js
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;'
```