Last active
March 15, 2020 09:55
-
-
Save marschhuynh/8f0f49801e95dfdaa22d140c3e9b900e to your computer and use it in GitHub Desktop.
Sock proxy
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 | |
SERVER=gg-sing | |
HOST=localhost | |
PORT=8123 | |
SOCK_ID=$(date +%s) | |
ssh -CNM -f -q -D 8123 -S /tmp/proxy-${SOCK_ID}.sock ${SERVER} | |
sudo networksetup -setsocksfirewallproxy "Wi-Fi" localhost 8123 | |
COMMAND="" | |
while [ "$COMMAND" != "q" ]; | |
do | |
clear | |
echo "=========== Mini proxy tools ===========" | |
echo "\t Press 'q' to quit." | |
read COMMAND | |
done | |
sudo networksetup -setsocksfirewallproxystate "Wi-Fi" off | |
ssh -S /tmp/proxy-${SOCK_ID}.sock -O exit ${SERVER} | |
# -D: Tells SSH that we want a SOCKS tunnel on the specified port number (you can choose a number between 1025-65536) | |
# -f: Forks the process to the background | |
# -C: Compresses the data before sending it | |
# -q: Uses quiet mode | |
# -N: Tells SSH that no command will be sent once the tunnel is up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment