An open API service indexing awesome lists of open source software.

https://github.com/shadowsocks/pacrunner


https://github.com/shadowsocks/pacrunner

Last synced: 9 months ago
JSON representation

Awesome Lists containing this project

README

          

# PACRunner

[![Build Status](https://travis-ci.org/komsomolskinari/pacrunner.svg?branch=master)](https://travis-ci.org/komsomolskinari/pacrunner)
[![Coverage Status](https://coveralls.io/repos/github/komsomolskinari/pacrunner/badge.svg?branch=master)](https://coveralls.io/github/komsomolskinari/pacrunner?branch=master)
[![npm version](https://badge.fury.io/js/pacrunner.svg)](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;'
```