Skip to content

Instantly share code, notes, and snippets.

@ruggertech
Created May 23, 2019 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruggertech/fcd93f11d6ce16abbc76e90adcc392a2 to your computer and use it in GitHub Desktop.
Save ruggertech/fcd93f11d6ce16abbc76e90adcc392a2 to your computer and use it in GitHub Desktop.
turn free proxy on, using mac command line
#!/bin/sh
SERVICE="Thunderbolt Ethernet Slot 1" # or "Wi-Fi"
echo $PROXYHOST
while [[ $# > 0 ]]
do
case "$1" in
on)
PROXYHOST="$(curl "http://pubproxy.com/api/proxy?limit=1&format=txt&type=socks5&https=true&google=true")"
PROXY_HOST=${PROXYHOST%%:*}
PROXY_PORT=${PROXYHOST##*:}
echo $PROXY_HOST
echo $PROXY_PORT
networksetup -setwebproxystate "$SERVICE" on
networksetup -setwebproxy "$SERVICE" $PROXY_HOST $PROXY_PORT off
networksetup -setsecurewebproxystate "$SERVICE" on
networksetup -setsecurewebproxy "$SERVICE" $PROXY_HOST $PROXY_PORT off
echo 'Web proxy is on'
shift
;;
off)
networksetup -setwebproxystate "$SERVICE" off
networksetup -setsecurewebproxystate "$SERVICE" off
echo 'Web proxy is off'
shift
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment