Skip to content

Commit

Permalink
Fixed sshproxy command issues
Browse files Browse the repository at this point in the history
  • Loading branch information
eko committed Jun 16, 2018
1 parent 4253058 commit 2b20b52
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .functions
Expand Up @@ -177,16 +177,14 @@ function selectnetworkinterface() {
2) selected="Wi-Fi";;
*) echo "Invalid option"; return;;
esac

return $selected
}

# Sets Cloudflare DNS servers on a network interface
function opendns() {
selectnetworkinterface

echo "\n-> Setting open DNS servers on network interface '$selected'"
networksetup -setdnsservers $selected 1.1.1.1 1.0.0.1
networksetup -setdnsservers "$selected" 1.1.1.1 1.0.0.1
}

# Sets SSH proxy on a network interface
Expand All @@ -196,8 +194,9 @@ function sshproxy() {
selectnetworkinterface

if [[ $1 == "stop" ]]; then
networksetup -setsocksfirewallproxystate $selected off
networksetup -setsocksfirewallproxystate "$selected" off
ps x | grep "[s]sh -fN -D 5000" | awk '{print $1}' | xargs kill -9
export http_proxy= https_proxy=

echo "\n-> Done: proxy is stopped and SSH connection is closed"

Expand All @@ -207,7 +206,9 @@ function sshproxy() {
echo "\n-> Setting socks proxy on network interface '$selected'"

ssh -fN -D 5000 $1
networksetup -setsocksfirewallproxy $selected localhost 5000
networksetup -setsocksfirewallproxy "$selected" localhost 5000
networksetup -setsocksfirewallproxystate "$selected" on
export http_proxy=socks5://127.0.0.1:5000 https_proxy=socks5://127.0.0.1:5000

echo "-> Done: proxy is ready"
}
Expand Down

0 comments on commit 2b20b52

Please sign in to comment.