From e9aedfe1ad1444a68f86f105b2fc1bac943b4be8 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sun, 15 May 2016 18:20:46 +0200 Subject: [PATCH] tor.sh: fix resetting proxy settings --- bin/tor.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/bin/tor.sh b/bin/tor.sh index 6ba2574..37da4b1 100755 --- a/bin/tor.sh +++ b/bin/tor.sh @@ -6,8 +6,8 @@ # Usage: # just run tor.sh in Terminal, kill with ctrl + c # ---------------------------------------------------------------------- -# loosely based on -# http://leonid.shevtsov.me/en/an-easy-way-to-use-tor-on-os-x +# more info: +# https://kremalicious.com/simple-tor-setup-on-mac-os-x/ # ###################################################################### # 'Wi-Fi' or 'Ethernet' or 'Display Ethernet' @@ -19,8 +19,23 @@ sudo -v # Keep-alive: update existing `sudo` time stamp until finished while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & +# trap ctrl-c and call disable_proxy() +function disable_proxy() { + sudo networksetup -setsocksfirewallproxystate $INTERFACE off + echo "$(tput setaf 64)" #green + echo "SOCKS proxy disabled." + echo "$(tput sgr0)" # color reset +} +trap disable_proxy INT + # Let's roll sudo networksetup -setsocksfirewallproxy $INTERFACE 127.0.0.1 9050 off sudo networksetup -setsocksfirewallproxystate $INTERFACE on + +echo "$(tput setaf 64)" # green +echo "SOCKS proxy 127.0.0.1:9050 enabled." +echo "$(tput setaf 136)" # orange +echo "Starting Tor..." +echo "$(tput sgr0)" # color reset + tor -sudo networksetup -setsocksfirewallproxystate $INTERFACE off