This file contains 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
# Original shell script was written by Adam Stankiewicz (@sheerun) | |
# https://gist.github.com/sheerun/3885694 | |
# | |
# Added on/off of "Web Proxy (HTTP)" for GlimmerBlocker users. | |
[[ -n "$1" ]] || { echo "Usage: proxy user@example.com"; exit 1; } | |
# get service GUID and NAME (like Wi-Fi) to set SOCKS proxy | |
SERVICE_GUID=`printf "open\nget State:/Network/Global/IPv4\nd.show" | \ | |
scutil | grep "PrimaryService" | awk '{print $3}'` | |
SERVICE_NAME=`printf "open\nget Setup:/Network/Service/$SERVICE_GUID\nd.show" |\ | |
scutil | grep "UserDefinedName" | awk -F': ' '{print $2}'` | |
# command to disble socks proxy after at the end | |
finally() | |
{ | |
sudo networksetup -setwebproxy "$SERVICE_NAME" 127.0.0.1 8228 && | |
sudo networksetup -setsocksfirewallproxystate "$SERVICE_NAME" off; | |
} | |
# enable socks proxy in system configuration | |
sudo networksetup -setwebproxystate "$SERVICE_NAME" off && | |
sudo networksetup -setsocksfirewallproxy "$SERVICE_NAME" 127.0.0.1 1080 && | |
ssh $1 -N -D 1080 | |
trap finally INT | |
finally |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment