Tests a PAC file and returns its output.
npm install pac-file-tester -g
pac-file-tester -f http://your.site/proxy.pac -u http://www.google.com
# or with npx
npx pac-file-tester -f http://your.site/proxy.pac -u http://www.google.com
- -f --file, the url/path of the pac file to test.
- -u --url, the url to test the pac file against.
- -i --ip, the IP address to return from
myIpAddress()
- -c --compare, the url/path of another pac file to compare output & speed with. (Optional)
- -d --dns, a manual DNS entry, e.g.
dns.google.com|8.8.8.8
- -v --verbose, enables verbose during operation
npm install --save pac-file-tester
Returns the contents of the given url, suppports http
and file
addresses.
const contents = await getFileContents('http://pac.example.com/proxy.pac')
Tests the PAC file for the given url.
Takes an optional options object with the following keys:
Key | Default | Description |
---|---|---|
ip | your current ip | The IP Address to return for myIpAddress() |
dnsEntries | {} |
DNS Entries to supply to the context. e.g. {'www.example.com': '1.2.3.4'} |
Run a PAC file from disk for https://www.google.com
.
const file = await getFileContents('file://./proxy.pac')
const result = await testPacFile(file, 'https://www.google.com')
Run a PAC file from a web server for https://www.google.com
whilst
impersonating the IP address 192.168.2.10
.
const file = await getFileContents('http://pac.example.com/proxy.pac')
const result = await testPacFile(file, 'https://www.google.com', {
ip: '192.168.2.10'
})
Run a PAC file from a web server for https://www.google.com
with a custom DNS
entry for example.com
that resolves to 127.0.0.1
const file = await getFileContents('http://pac.example.com/proxy.pac')
const result = await testPacFile(file, 'https://www.google.com', {
dnsEntries: {'example.com': '127.0.0.1'}
})