Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added sshproxy and stopsshproxy functions
  • Loading branch information
eko committed Jun 2, 2018
1 parent c6f8f29 commit f9ea808
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 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,41 @@ 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>
function sshproxy() {
selectnetworkinterface

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

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

echo "\n-> All set, proxy is ready"
}

# Sets SSH proxy on a network interface
# Usage: stopsshproxy
function stopsshproxy() {
selectnetworkinterface

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

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

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

0 comments on commit f9ea808

Please sign in to comment.