Skip to content

Instantly share code, notes, and snippets.

@idiomer
Last active February 5, 2020 09:19
Show Gist options
  • Save idiomer/c808f86b9a06e2e9b9c1a7dd16e019c4 to your computer and use it in GitHub Desktop.
Save idiomer/c808f86b9a06e2e9b9c1a7dd16e019c4 to your computer and use it in GitHub Desktop.
#!/bin/bash
deactive_proxy () {
if [ ! "$1" = "nondestructive" ] ; then
unset -f deactive_proxy
if [ -n "$_OLD_HTTP_PROXY" ] ; then
http_proxy="$_OLD_HTTP_PROXY"
export http_proxy
unset _OLD_HTTP_PROXY
else
unset http_proxy
fi
if [ -n "$_OLD_HTTPS_PROXY" ] ; then
https_proxy="$_OLD_HTTPS_PROXY"
export https_proxy
unset _OLD_HTTPS_PROXY
else
unset https_proxy
fi
fi
}
deactive_proxy nondestructive
if [ -n "$http_proxy" ] ; then
_OLD_HTTP_PROXY="$http_proxy"
export _OLD_HTTP_PROXY
unset http_proxy
fi
if [ -n "$https_proxy" ] ; then
_OLD_HTTPS_PROXY="$https_proxy"
export _OLD_HTTPS_PROXY
unset https_proxy
fi
port="1090"
host="192.168.0.103"
http_proxy=http://${host}:${port}
https_proxy=http://${host}:${port}
export http_proxy
export https_proxy
@idiomer
Copy link
Author

idiomer commented Feb 5, 2020

active proxy

source active_proxy.sh

deactive proxy

deactive_proxy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment