update bash function

This commit is contained in:
thek4n 2023-12-05 14:48:25 +03:00
parent 2188c2fbec
commit d21b0bf01a

View File

@ -131,15 +131,20 @@ vpn() {
} }
toggle-ssh-proxy() { toggle-ssh-proxy() {
if [ -v http_proxy ]; then SSH_PROXY_CONTROL_FILE="$XDG_RUNTIME_DIR/ssh_$1_proxy.control"
unset {http,https,ftp,rsync,no}_proxy
echo "Disabled"
else
if [ -z "$1" ]; then if [ -z "$1" ]; then
echo "Proxy ssh server hostname not specified" 1>&2 echo "Proxy ssh server hostname not specified" 1>&2
return 1 return 1
fi fi
ssh -vCTN -D 1080 "$1" 1>/dev/null 2>&1 &
if [ -e "$SSH_PROXY_CONTROL_FILE" ]; then
unset {http,https,ftp,rsync,no}_proxy
ssh -S "$SSH_PROXY_CONTROL_FILE" -O exit "$1"
unset SSH_PROXY_PID
echo "Disabled"
else
ssh -nCTN -S "$SSH_PROXY_CONTROL_FILE" -D 1080 "$1"
export {http,https,ftp,rsync}_proxy="socks5://127.0.0.1:1080" && \ export {http,https,ftp,rsync}_proxy="socks5://127.0.0.1:1080" && \
export no_proxy="localhost,127.0.0.1/8,localaddress,.localdomain.com,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12" export no_proxy="localhost,127.0.0.1/8,localaddress,.localdomain.com,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12"
echo "Enabled" echo "Enabled"