From e711c69ac76be45af560bffe68293b667ed96317 Mon Sep 17 00:00:00 2001 From: James Patrick Date: Tue, 7 May 2024 10:23:36 -0400 Subject: [PATCH] zsh bin: +tubeosock for remote tunneling --- zsh/modules/bin/tubesock | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 zsh/modules/bin/tubesock diff --git a/zsh/modules/bin/tubesock b/zsh/modules/bin/tubesock new file mode 100755 index 0000000..7f4761d --- /dev/null +++ b/zsh/modules/bin/tubesock @@ -0,0 +1,24 @@ +#!/bin/bash +# +# The script tunnels all traffic on a machine to a remote hosts. It setups a +# socks proxy then tunnels to machine via ssh. This can be use useful when you +# need to test apis only accept connections from a whitelisted ip. +# +# This script is mac specific. There is likely a way to generalize the +# configuration of the socks proxy, but this currently don't do that. +# +# Usage: tubesock example.com + +clean_up(){ + networksetup -setsocksfirewallproxystate wi-fi off + echo "Goodbye." + exit 0 +} +trap clean_up INT + +echo "Configuring..." +networksetup -setsocksfirewallproxy wi-fi 127.0.0.1 1111 +echo "Socks proxy enabled" + +echo "Tunneling..." +ssh -ND 1111 "${1}"