/
shell-proxy
39 lines (37 loc) · 1.36 KB
/
shell-proxy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env zsh
# Shell proxy
function shell-proxy(){
if [ "$1" = "on" ]; then
echo "Turning on shell proxy."
if [[ ! -z $IDLEBOX_SHELL_PROXY_SERVER_ALL ]];then
export all_proxy=$IDLEBOX_SHELL_PROXY_SERVER_ALL
export ALL_PROXY=$IDLEBOX_SHELL_PROXY_SERVER_ALL
echo "Proxy \"ALL\" with $IDLEBOX_SHELL_PROXY_SERVER_ALL"
fi
if [[ ! -z $IDLEBOX_SHELL_PROXY_SERVER_HTTP ]];then
export http_proxy=$IDLEBOX_SHELL_PROXY_SERVER_HTTP
export HTTP_PROXY=$IDLEBOX_SHELL_PROXY_SERVER_HTTP
echo "Proxy \"HTTP\" with $IDLEBOX_SHELL_PROXY_SERVER_HTTP"
fi
if [[ ! -z $IDLEBOX_SHELL_PROXY_SERVER_HTTPS ]];then
export https_proxy=$IDLEBOX_SHELL_PROXY_SERVER_HTTPS
export HTTPS_PROXY=$IDLEBOX_SHELL_PROXY_SERVER_HTTPS
echo "Proxy \"HTTPS\" with $IDLEBOX_SHELL_PROXY_SERVER_HTTPS"
fi
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
export NO_PROXY="localhost,127.0.0.1,localaddress,.localdomain.com"
elif [ "$1" = "off" ]; then
echo "Turning off shell proxy."
unset all_proxy
unset ALL_PROXY
unset http_proxy
unset HTTP_PROXY
unset https_proxy
unset HTTPS_PROXY
unset no_proxy
unset NO_PROXY
else
echo "Invalid param. Please input 'shell-proxy on' or 'shell-proxy off' to switch shell proxy."
fi
curl http://www.cip.cc/`curl -s curl ifconfig.me`
}