Skip to content

Instantly share code, notes, and snippets.

@marionebl
Created May 30, 2019 11:27
Show Gist options
  • Save marionebl/d032f9903455e7525b1a711e5a68a5e4 to your computer and use it in GitHub Desktop.
Save marionebl/d032f9903455e7525b1a711e5a68a5e4 to your computer and use it in GitHub Desktop.
SOCKS5 proxy helper script for macOS
function __prox_on
if not ssh -q -O check scaleway 2> /dev/null
ssh -M -Nf -D 1080 scaleway
end
networksetup -setsocksfirewallproxy "Wi-Fi" localhost 1080
networksetup -setsocksfirewallproxystate "Wi-Fi" on
end
function __prox_off
if ssh -q -O check scaleway 2> /dev/null
ssh -q -O exit scaleway 2> /dev/null
end
networksetup -setsocksfirewallproxystate "Wi-Fi" off
end
function __prox_status
if ssh -q -O check scaleway 2> /dev/null
echo "on"
else
echo "off"
end
end
function prox
if test "$argv[1]" = "on"
__prox_on
true
else if test "$argv[1]" = "off"
__prox_off
true
else if test "$argv[1]" = "status"
__prox_status
true
else
echo "command required - on, off, status"
false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment