我想在我的 squid 代理服务器上匿名浏览和抓取,使用 10 个 IP 地址,因此每 20 秒自动更改 IP 地址。有没有人知道具体该如何实现?
我尝试过下面的代码,但没有帮助。
#!/bin/bash
base_socks_port=9050
base_http_port=3129 # leave 3128 for HAProxy
base_control_port=8118
# Create data directory if it doesn't exist
if [ ! -d "data" ]; then
mkdir "data"
fi
for i in {0..9}
do
j=$((i+1))
socks_port=$((base_socks_port+i))
control_port=$((base_control_port+i))
http_port=$((base_http_port+i))
if [ ! -d "data/tor$i" ]; then
echo "Creating directory data/tor$i"
mkdir "data/tor$i"
fi
# Take into account that authentication for the control port is disabled. Must be used in secure and controlled environments
echo "Running: tor --RunAsDaemon 1 --CookieAuthentication 0 --HashedControlPassword \"\" --ControlPort $control_port --PidFile tor$i.pid --SocksPort $socks_port --DataDirectory data/tor$i"
tor --RunAsDaemon 1 --CookieAuthentication 0 --HashedControlPassword "" --ControlPort $control_port --PidFile tor$i.pid --SocksPort $socks_port --DataDirectory data/tor$i
echo "Running: ./delegate/src/delegated -P$http_port SERVER=http SOCKS=localhost:$socks_port"
./delegate/src/delegated -P$http_port SERVER=http SOCKS=localhost:$socks_port
done
haproxy -f rotating-tor-proxies.cfg