前情提要
最近发现网络波动变得越来越严重,所以需要在网络通信上附加点方法
WSL2
用 vim ~/.bashrc 编辑一下,此方法能够代理git apt 以及部分命令行的http/https应用
P.S.其中的7890端口自行修改
export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*')
alias proxy='
echo "${hostip}"
git config --global http.proxy http://${hostip}:7890
git config --global https.proxy http://${hostip}:7890
export https_proxy="socks5://${hostip}:7890";
export http_proxy="socks5://${hostip}:7890";
export all_proxy="socks5://${hostip}:7890";
echo -e "Acquire::http::Proxy \"http://${hostip}:7890\";" | sudo tee -a /etc/apt/apt.conf.d/proxy.conf > /dev/null;
echo -e "Acquire::https::Proxy \"http://${hostip}:7890\";" | sudo tee -a /etc/apt/apt.conf.d/proxy.conf > /dev/null;
'
alias unproxy='
unset https_proxy;
unset http_proxy;
unset all_proxy;
git config --global --unset http.proxy
git config --global --unset https.proxy
sudo sed -i -e '/Acquire::http::Proxy/d' /etc/apt/apt.conf.d/proxy.conf;
sudo sed -i -e '/Acquire::https::Proxy/d' /etc/apt/apt.conf.d/proxy.conf;
'
在bash中用proxy应用代理,unproxy取消代理
Git
git config --global http.proxy http://127.0.0.1:7890 git config --global https.proxy http://127.0.0.1:7890
待续未完
