-
-
Save m3nt0r/5897435 to your computer and use it in GitHub Desktop.
Added "start" command which creates a local SSH tunnel to a pre-configured server. The connection may then be used as SOCKS proxy within the Mac OSX network settings (and this toggle script)
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
#!/bin/sh | |
[email protected] | |
SSH_PORT=22 | |
PROXY_INTERFACE="Wi-Fi" | |
PROXY_HOST=localhost | |
PROXY_PORT=8080 | |
if [[ $1 == "start" ]]; then | |
ssh -D $PROXY_PORT -f -C -q -N $SSH_HOST -p$SSH_PORT | |
echo "SSH Tunnel created." | |
echo "======================================================" | |
ps ax | grep $PROXY_PORT | head -n 1 | |
echo "======================================================" | |
elif [[ $1 == "on" ]]; then | |
sudo networksetup -setsocksfirewallproxy "$PROXY_INTERFACE" $PROXY_HOST $PROXY_PORT | |
echo "SOCKS proxy enabled" | |
elif [[ $1 == "off" ]]; then | |
sudo networksetup -setsocksfirewallproxystate "$PROXY_INTERFACE" off | |
echo "SOCKS proxy disabled" | |
elif [[ $1 == "status" ]]; then | |
echo "======================================================" | |
echo "Network Services:" | |
echo "======================================================" | |
networksetup -listallnetworkservices | |
echo | |
echo "======================================================" | |
echo "Current SOCKS Proxy Settings:" | |
echo "======================================================" | |
networksetup -getsocksfirewallproxy "$PROXY_INTERFACE" | |
echo | |
else | |
echo "`basename $0` toggles SOCKS proxy settings on OS X" | |
echo | |
echo "Usage: " | |
echo " $ proxy start # start SSH tunnel to use as SOCKS proxy" | |
echo " $ proxy on # turns SOCKS proxy on" | |
echo " $ proxy off # turns SOCKS proxy off" | |
echo " $ proxy status # prints status of proxy settings" | |
echo | |
echo "proxy interface: " $PROXY_INTERFACE | |
echo "proxy host: " $PROXY_HOST | |
echo "proxy port: " $PROXY_PORT | |
echo | |
exit 65 # end process with error to indicate incorrect arguments | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have changed my fork to accommodate the above. It works great!