-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathproxy
More file actions
53 lines (47 loc) · 1.13 KB
/
proxy
File metadata and controls
53 lines (47 loc) · 1.13 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
setproxy() {
export http_proxy=http://127.0.0.1:10808
export https_proxy=http://127.0.0.1:10808
export all_proxy=socks5://127.0.0.1:10808
export HTTP_PROXY=http://127.0.0.1:10808
export HTTPS_PROXY=http://127.0.0.1:10808
export ALL_PROXY=socks5://127.0.0.1:10808
export no_proxy="localhost,127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
export NO_PROXY="$no_proxy"
echo "Proxy settings is turned on"
}
unsetproxy() {
unset http_proxy
unset https_proxy
unset all_proxy
unset HTTP_PROXY
unset HTTPS_PROXY
unset ALL_PROXY
unset no_proxy
unset NO_PROXY
echo "Proxy settings turned off"
}
_proxyusage() {
echo "Set or unset proxy settings for the current session"
echo "Usage: proxy [on|off]"
return 0
}
proxy() {
if [[ "$#" -eq 0 ]]; then
_proxyusage
return 0
fi
if [[ "$1" == "on" ]]; then
setproxy
elif [[ "$1" == "off" ]]; then
unsetproxy
else
echo "Unknown argument: $@"
_proxyusage
return 1
fi
}
autosetproxy() {
if [[ "$AUTO_SET_PROXY" == "1" ]]; then
setproxy
fi
}