Skip to content

Instantly share code, notes, and snippets.

@piroux
Forked from goodell/proxy-kvm.pac
Last active July 1, 2016 22:08
Show Gist options
  • Save piroux/69414c5af0b9bf9fd79e2df27be30b92 to your computer and use it in GitHub Desktop.
Save piroux/69414c5af0b9bf9fd79e2df27be30b92 to your computer and use it in GitHub Desktop.
function FindProxyForURL(url, host) {
// access the CIMCs via the SSH-tunneled SOCKS proxy that is hopefully
// running on port 8181, but allow fallback if it's not running
if (isInNet(dnsResolve(host), "10.0.7.0", "255.255.255.0")) {
return "SOCKS localhost:8181; DIRECT";
}
// Everything else directly!
return "DIRECT";
}
#!/bin/zsh
# PAC file that proxies via SOCKS on localhost:8080 for accesses to 10.0.7.0/24
# addresses (i.e., the CIMCs for the savbu-usnic cluster)
pac_file=https://gist.githubusercontent.com/piroux/69414c5af0b9bf9fd79e2df27be30b92/raw/cimc-proxy.pac
#interface="${1:=Ethernet 2}"
#interface="${1:=Wi-Fi}"
interface="${1:=Display Ethernet}"
set -x
function enable_proxy() {
sudo networksetup -setautoproxyurl "$interface" $pac_file
sudo networksetup -setautoproxystate "$interface" on
}
function disable_proxy() {
# setting state off seems to clear the URL too
#sudo networksetup -setautoproxyurl "$interface" ''
sudo networksetup -setautoproxystate "$interface" off
}
enable_proxy
trap disable_proxy 0 SIGHUP SIGINT SIGQUIT SIGTERM
ssh -T -N -v -D localhost:8181 savbu-usnic
trap -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment