2.1.0 • Published 2 years ago

pac-file-tester v2.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Pac File Tester

codecov buid status NPM

Tests a PAC file and returns its output.

Usage

As a CLI tool

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

Options

  • -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

Pragmatically

npm install --save pac-file-tester

getFileContents(url: string): Promise<string>

Returns the contents of the given url, suppports http and file addresses.

const contents = await getFileContents('http://pac.example.com/proxy.pac')

testPacFile(file: string, url: string, options: Options)

Tests the PAC file for the given url.

Takes an optional options object with the following keys:

KeyDefaultDescription
ipyour current ipThe IP Address to return for myIpAddress()
dnsEntries{}DNS Entries to supply to the context. e.g. {'www.example.com': '1.2.3.4'}
Examples
Local file

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')
Remote file with replaced IP

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'
})
Remote file with a custom DNS entry

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'}
})
2.1.0

2 years ago

1.3.1

3 years ago

2.0.0

3 years ago

1.2.0

3 years ago

1.3.0

3 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago