Skip to content

Commit

Permalink
Added sshproxy and stopsshproxy functions
Browse files Browse the repository at this point in the history
  • Loading branch information
eko committed Jun 2, 2018
1 parent c6f8f29 commit 05c2957
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions .functions
Expand Up @@ -167,8 +167,8 @@ function lighthouse {
fi
}

# Sets Cloudflare DNS servers on a network interface
function opendns() {
# Asks the user to select a network interface and returns the result
function selectnetworkinterface() {
echo "Select the network interface:\n1) Belkin USB-C LAN\n2) Wi-Fi"
read n

Expand All @@ -178,10 +178,40 @@ function opendns() {
*) 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
}

# Sets SSH proxy on a network interface
# Usage: sshproxy <user>@<ip>
# Usage: sshproxy stop
function sshproxy() {
selectnetworkinterface

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

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

return
fi

echo "\n-> Setting socks proxy on network interface '$selected'"

ssh -fN -D 5000 $1
networksetup -setsocksfirewallproxy $selected localhost 5000

echo "-> Done: proxy is ready"
}

# Automatically Starting tmux on SSH
function ssht() {
SSH_HOST="${@: -1}"
Expand Down

0 comments on commit 05c2957

Please sign in to comment.