我有一个使用 3proxy 创建 IPv6 代理的 bash 脚本。它工作得很好。我想添加一个名为的新功能rotating
。基本上,这种轮换模式会将 IPv6 地址添加到网络接口并每秒更改 3proxy 的配置文件n
。如果我在激活此模块后(注销/等待一段时间),代理在更改后将无法工作。我猜这是因为未应用系统限制。我该如何修复它?我在下面留下了我的脚本:
cd /home/proxyolusturucu/cronisleri
rm -rf /home/proxyolusturucu/cronisleri/ipyapici$IPV6SUBNET.sh
cat <<EOF >> /home/proxyolusturucu/cronisleri/ipyapici$IPV6SUBNET.sh # This one creates a bash script to create random IPv6 addresses
#!/bin/bash
rm -rf /home/proxyolusturucu/cronisleri/ipolustur$IPV6SUBNET.sh
echo "#!/bin/bash
IPV6=\"${IPV6}\"
IPV6SUBNET=\"$IPV6SUBNET\"" >> /home/proxyolusturucu/cronisleri/ipolustur$IPV6SUBNET.sh
echo 'ipv6_k=(1 2 3 4 5 6 7 8 9 0 a b c d e f)
ipv6_olustur() {
ipv6_ver() {
echo "\${ipv6_k[\$RANDOM % 16]}\${ipv6_k[\$RANDOM % 16]}\${ipv6_k[\$RANDOM % 16]}\${ipv6_k[\$RANDOM % 16]}"
}
if [[ \$IPV6SUBNET == "64" ]]; then
echo "\$1:\$(ipv6_ver):\$(ipv6_ver):\$(ipv6_ver):\$(ipv6_ver)"
elif [[ \$IPV6SUBNET == "32" ]]; then
echo "\$1:\$(ipv6_ver):\$(ipv6_ver):\$(ipv6_ver):\$(ipv6_ver):\$(ipv6_ver):\$(ipv6_ver)"
fi
}
YENIPV6(){
echo "\${IPV6}\$(ipv6_olustur)"
}
' >> /home/proxyolusturucu/cronisleri/ipolustur$IPV6SUBNET.sh
EOF
bash ipyapici$IPV6SUBNET.sh
cat <<EOF >> /home/proxyolusturucu/cronisleri/ipdegis$yeniconfigadi.sh # This one does the main job. It changes the configuration file of 3proxy and adds IPv6 addresses to interface.
#!/bin/bash
ulimit -Hn 600000
ulimit -Hu 600000
source /home/proxyolusturucu/cronisleri/ipolustur$IPV6SUBNET.sh
yeniconfigadi="${yeniconfigadi}"
cd /home/proxyolusturucu/3proxy
rm -rf ipekle\$yeniconfigadi.sh
pidim=\$\$
tmpdosya=\$(mktemp)
while read -r ipler; do
if [[ \$ipler == *"-e"* ]]; then
ipler2=\$(echo "\$ipler" | grep -oP '(?<=-e)\S+')
yeni_ipler=\$(YENIPV6 "\$ipler2")
for ipadresleri in \$yeni_ipler; do
echo "/usr/sbin/ip -6 addr add \$ipadresleri/$IPV6SUBNET dev $kbadi" >> ipekle\$yeniconfigadi.sh
done
ipler=\${ipler/"-e\$ipler2"/"-e\$yeni_ipler"}
fi
echo "\$ipler" >> "\$tmpdosya"
done < "\$yeniconfigadi"
mv -f "\$tmpdosya" "\$yeniconfigadi"
for pid in \$(pgrep 3proxy); do
if [ \$pid -ne \$pidim ]; then
kill \$pid
fi
done
sed -i '1s/^/ulimit -Hn 600000\nulimit -Hu 600000\n/' ipekle\$yeniconfigadi.sh
sudo bash ipekle\$yeniconfigadi.sh
sudo bash ipcikar\$yeniconfigadi.sh
rm -rf ipcikar\$yeniconfigadi.sh
cp ipekle\$yeniconfigadi.sh ipcikar\$yeniconfigadi.sh
sed -i "s@addr add@addr del@g" ipcikar\$yeniconfigadi.sh
sleep 7
for configler in 3proxy.config*; do 3proxy "\$configler"; done
EOF
echo "#!/bin/bash # We are creating another bash script to run it every n seconds.
ulimit -Hn 600000
ulimit -Hu 600000
while true; do
sleep $refleshsaniye
cd /home/proxyolusturucu/cronisleri; chmod 777 ipdegis$yeniconfigadi.sh; ./ipdegis$yeniconfigadi.sh
done" >> cron$yeniconfigadi.sh
bash cron$yeniconfigadi.sh &
我试过:
Using crontab, systemd services, changing "bash cron$yeniconfigadi.sh &" with "bash cron$yeniconfigadi.sh & disown", changing "bash cron$yeniconfigadi.sh &" with "nohup bash cron$yeniconfigadi.sh &"