This commit is contained in:
luk
2024-05-30 12:22:31 +08:00
parent fc712a068f
commit 6f5a2fb6d8
5 changed files with 52 additions and 24 deletions

View File

@@ -3,26 +3,31 @@
echo "=== Please run with 'source proxy.sh', otherwise it has no effect on the current shell"
if [ -n "$1" ]; then
proxySwitch="$1"
proxySwitch="$1"
else
echo "=== 开启或关闭网络代理? [s/1] for start, [t/0] for terminate, [anything else] for no change."
read -p ">>> " proxySwitch
echo "=== 开启或关闭网络代理? [s/1] for start, [t/0] for terminate, [anything else] for no change."
read -p ">>> " proxySwitch
fi
# function proxy() {
if [ "$proxySwitch" == "s" ] || [ "$proxySwitch" == "1" ]; then
export all_proxy=socks5://127.0.0.1:7898
export http_proxy=socks5://127.0.0.1:7898
export https_proxy=socks5://127.0.0.1:7898
echo -e "--- 已开启网络代理"
elif [ "$proxySwitch" == "t" ] || [ "$proxySwitch" == "0" ]; then
unset all_proxy
unset http_proxy
unset https_proxy
echo -e "--- 已关闭网络代理"
else
echo "--- Nothing changed."
fi
if [ "$proxySwitch" == "s" ] || [ "$proxySwitch" == "1" ]; then
echo "=== Proxy server running on port number: "
while [ ! "$PORT" ]
do
read -p ">>> " PORT
done
export all_proxy=socks5://127.0.0.1:$PORT
export http_proxy=socks5://127.0.0.1:$PORT
export https_proxy=socks5://127.0.0.1:$PORT
echo -e "--- 已开启网络代理"
elif [ "$proxySwitch" == "t" ] || [ "$proxySwitch" == "0" ]; then
unset all_proxy
unset http_proxy
unset https_proxy
echo -e "--- 已关闭网络代理"
else
echo "--- Nothing changed."
fi
# }
echo all_proxy="$all_proxy"