24 lines
701 B
Bash
Executable File
24 lines
701 B
Bash
Executable File
#!/usr/bin/env zsh
|
|
# Opens SOCKS5 proxy over SSH
|
|
|
|
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
|
|
|
zmodload zsh/zutil
|
|
local -a o_help=()
|
|
local -a o_port=()
|
|
zparseopts -D -K -- h=o_help -port:=o_port
|
|
if [[ ${#o_help} -ne 0 || ! -v 1 ]]; then
|
|
local ret=$(( ${#o_help} ^ 1 ))
|
|
print -u $(( 1 + ${ret} )) "usage: ${0} [-h] <HOST>"
|
|
return ${ret}
|
|
fi
|
|
local host=${1}
|
|
local port="1080"
|
|
[[ ${#o_port} -eq 2 ]] && port=${o_port[2]}
|
|
|
|
print -P "%F{12}starting SOCKS5 proxy over SSH tunnel to" \
|
|
"%F{magenta}${host}%f %F{12}on %F{13}[::1]:${port}%f %F{12}…"
|
|
print -P "%F{12}curl environment variable:" \
|
|
"%F{13}ALL_PROXY='socks5://[::1]:${port}'%f"
|
|
ssh -D "[::1]:${port}" -N -T ${host}
|