Alan3
2022-12-12 15:25:13 +08:00
在多用户的 linux 下,自用,
1. 安装好 proxychains
```
alias pc=/path/to/proxychains4
```
2. 启动和关闭脚本 naive,这里代理软件以 naiveproxy 为例子
```
#!/usr/bin/sh
function rand(){
min=$1
max=$(($2-$min+1))
num=$(date +%s%N)
echo $(($num%$max+$min))
}
rndport=$(rand 20000 60000)
if [ $1 == "-h" -o $1 == "--help" ];then
echo '
##usage:
*if u wana proxy via proxychains:
`naive start`
then, `proxychains4 command_line`
`naive stop`
'
exit
fi
naive_path=/path/to/naiveproxy
mkdir -p ~/.gofree
if [ $1 == "start" ];then
cp $naive_path/config.json ~/.gofree/.json
cp $naive_path/naive ~/.gofree/fhbfcgdx$rndport
sed -i "s:1080:$rndport:g" ~/.gofree/.json
cd ~/.gofree
./fhbfcgdx$rndport ~/.gofree/.json > ~/.gofree/log.txt 2>&1 &
mkdir -p ~/.proxychains/
echo "[ProxyList]
socks5 127.0.0.1 $rndport
" > ~/.proxychains/proxychains.conf
echo "fhbfcgdx$rndport" >> p.txt
cd - > /dev/null
echo "start success!!"
fi
if [ $1 == "stop" ];then
cd ~/.gofree
pkill `cat p.txt | xargs` > /dev/null
# unset http_proxy
# unset https_proxy
# unset ALL_PROXY
rm -rf .json `cat p.txt | xargs` *.log log.txt p.txt
rm -rf fhbfcgdx* && echo "stop succes"
cd - > /dev/null
fi
```
比如我想要克隆仓库 或者 安装软件的时候,我就
naive start
pc git clone http://xxxxxx .
pc conda install xxxx
pc curl https://xxx
naive stop