Commit a00c0f10 authored by Willi Rath's avatar Willi Rath
Browse files

Add socks5 with chromium wrapper

parent 3df8927a
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
#!/bin/bash

# check inputs and print USAGE message
if [ $# -lt 1 ]; then
    echo "USAGE: " $0 "<tunnel-host> [URL]"
    echo "where <tunnel-host> can be of the form user@host."
    echo ""
    exit
fi

# read tunnel host and print info to screen
tunnel_host=$1
echo will route traffic through ${tunnel_host}

# read URL
URL=$2

# find free port
socks_5_port=`python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'`
echo using port $socks_5_port

# Open socks5 proxy which will close after 15 Seconds if the tunnel is not
# used.  Extension of sleep time necessary?
ssh -f -D localhost:${socks_5_port} ${tunnel_host} sleep 15
browser=chromium-browser
which chromium-browser || browser=chromium
${browser} --new-window --user-data-dir="/tmp/chromium_user_data_$(date -Ins)" --proxy-server="socks5://localhost:${socks_5_port}" ${URL}