-
-
Save macbre/f49e7723906cd1b6cbb1eddc45743da5 to your computer and use it in GitHub Desktop.
Proxy PAC file template for selective SSH SOCKS proxies, plus a [re]installation script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Proxy PAC File | |
| // https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Proxy_servers_and_tunneling/Proxy_Auto-Configuration_PAC_file | |
| function FindProxyForURL(url, host) { | |
| // Setup a SOCKS proxy on port 1280. | |
| proxy = "SOCKS5 127.0.0.1:1280; SOCKS 127.0.0.1:1280" | |
| // Log to `chrome://net-internals/#events` for debugging. | |
| alert("url: " + url + ", host: " + host) | |
| // Setup proxy filters. | |
| // - Use `host` for IP addresses and domain names. | |
| // - Use `url` for more control over the entire URL (i.e. sub paths). | |
| // - Protip: Use the above debugging log to determine the `url` and `host` for | |
| // a given page. | |
| // - Protip 2: If you add an entry for your server to `/etc/hosts` in the form of | |
| // `IP_address domain_name_url alias`, the `host` can be matched to the `alias`. | |
| if (shExpMatch(host, "111.111.111.*") || // match IP address | |
| shExpMatch(host, "server*")) { // match `server1`, `server23`, etc. | |
| // Log to `chrome://net-internals/#events` for debugging. | |
| alert(host + " passed!") | |
| // Route through server. | |
| return proxy; | |
| } | |
| // Route everything else directly! | |
| return "DIRECT"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -x # echo on | |
| DIR="$(cd "$(dirname "$0")" && pwd)" | |
| PROXY_FILE_PATH="$DIR/proxy.pac" | |
| sudo networksetup -setautoproxystate Wi-Fi off | |
| sudo networksetup -setautoproxyurl Wi-Fi file://$PROXY_FILE_PATH | |
| sudo networksetup -getautoproxyurl Wi-Fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment