-
-
Save fharbe/9493000 to your computer and use it in GitHub Desktop.
Revisions
-
ogawa revised this gist
Nov 28, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ SSH_HOST=proxy-host SOCKS_PROXY_HOST=localhost SOCKS_PROXY_PORT=1080 NW_SERVICE=Wi-Fi # /usr/sbin/networksetup -listallnetworkservices # DO NOT CHANGE NWSETUP_CMD="/usr/sbin/networksetup" -
ogawa revised this gist
Aug 31, 2011 . 1 changed file with 17 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,30 +7,32 @@ # Host proxy-host # HostName proxy-host.example.com # User a12345 # DynamicForward localhost:1080 # # Step 3. Configure SSH_HOST, SOCKS_PROXY_PORT, and NW_SERVICE variables. # SSH_HOST=proxy-host SOCKS_PROXY_HOST=localhost SOCKS_PROXY_PORT=1080 NW_SERVICE=AirPort # /usr/sbin/networksetup -listallnetworkservices # DO NOT CHANGE NWSETUP_CMD="/usr/sbin/networksetup" SSH_CMD="/usr/bin/ssh -Nf $SSH_HOST" SOCKS_PROXY_ENABLED= if $NWSETUP_CMD -getsocksfirewallproxy $NW_SERVICE | grep -q "^Enabled: Yes"; then SOCKS_PROXY_ENABLED=1 fi SSH_PID=`pgrep -f "$SSH_CMD"` enable_socks_proxy() { echo Enable SOCKS Firewall Proxy. $NWSETUP_CMD -setsocksfirewallproxy $NW_SERVICE $SOCKS_PROXY_HOST $SOCKS_PROXY_PORT off } disable_socks_proxy() { if [ $SOCKS_PROXY_ENABLED ]; then echo Disable SOCKS Firewall Proxy. $NWSETUP_CMD -setsocksfirewallproxystate $NW_SERVICE off fi @@ -71,21 +73,27 @@ case $1 in else echo SSH Connection to $SSH_HOST is dead. fi if [ $SOCKS_PROXY_ENABLED ]; then echo SOCKS Firewall Proxy is on. else echo SOCKS Firewall Proxy is off. fi ;; on) enable_socks_proxy ;; off) disable_socks_proxy ;; toggle) if [ $SOCKS_PROXY_ENABLED ]; then disable_socks_proxy else enable_socks_proxy fi ;; *) echo "Usage: $0 {start|stop|status|on|off|toggle|help}" exit 1 ;; esac -
ogawa revised this gist
Aug 1, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -38,7 +38,7 @@ disable_socks_proxy() { create_ssh_connection() { echo Create SSH Connection to $SSH_HOST. $SSH_CMD &> /dev/null } destroy_ssh_connection() { -
ogawa created this gist
Aug 1, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,93 @@ #!/bin/sh # # Step 1. Install proctools to use "pgrep" command. # # Step 2. Configure your .ssh/config to include: # # Host proxy-host # HostName proxy-host.example.com # User a12345 # DynamicForward 1080 # # Step 3. Configure SSH_HOST and NW_SERVICE variables: # SSH_HOST=proxy-host NW_SERVICE=AirPort # /usr/sbin/networksetup -listallnetworkservices # DO NOT CHANGE NWSETUP_CMD="/usr/sbin/networksetup" SSH_CMD="/usr/bin/ssh -Nf $SSH_HOST" SOCKS_PROXY= if $NWSETUP_CMD -getsocksfirewallproxy $NW_SERVICE | grep -q "^Enabled: Yes"; then SOCKS_PROXY=1 fi SSH_PID=`pgrep -f "$SSH_CMD"` enable_socks_proxy() { echo Enable SOCKS Firewall Proxy. $NWSETUP_CMD -setsocksfirewallproxystate $NW_SERVICE on } disable_socks_proxy() { if [ $SOCKS_PROXY ]; then echo Disable SOCKS Firewall Proxy. $NWSETUP_CMD -setsocksfirewallproxystate $NW_SERVICE off fi } create_ssh_connection() { echo Create SSH Connection to $SSH_HOST. $SSH_CMD } destroy_ssh_connection() { if [ $SSH_PID ]; then echo Destroy SSH Connection to $SSH_HOST. kill -TERM $SSH_PID fi } case $1 in start) destroy_ssh_connection create_ssh_connection enable_socks_proxy ;; stop) disable_socks_proxy destroy_ssh_connection ;; pid) if [ $SSH_PID ]; then echo $SSH_PID else echo SSH Connection to $SSH_HOST is dead. fi ;; status) if [ $SSH_PID ]; then echo SSH Connection to $SSH_HOST is alive \(PID:$SSH_PID\). else echo SSH Connection to $SSH_HOST is dead. fi if [ $SOCKS_PROXY ]; then echo SOCKS Firewall Proxy is on. else echo SOCKS Firewall Proxy is off. fi ;; toggle) if [ $SOCKS_PROXY ]; then disable_socks_proxy else enable_socks_proxy fi ;; *) echo "Usage: $0 {start|stop|status|toggle|help}" exit 1 ;; esac exit 0