前言
在vps上安装广告过滤软件配合shadowsocks,就可以实现代理+广告过滤。考虑到安全问题,只过滤HTTP内容,否则还得安装koolproxy的自定义证书,有安全隐患。
第一次运行脚本会安装koolproxy,以后再运行脚本就只更新规则了。防火墙规则重启之后失效,所以重启后需要再次运行脚本。
一键安装
1 2
| wget -O koolproxy.sh https://raw.githubusercontent.com/xiuluo/shell/master/koolproxy.sh bash koolproxy.sh
|
自动更新
1 2 3
| crontab -e
22 4 * * 0 /root/koolproxy.sh
|
卸载
1 2 3
| pkill -9 koolproxy rm -R koolproxy reboot
|
源代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| #!/usr/bin/env bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH folder="/root/koolproxy"
if [ ! -d "$folder" ]; then mkdir $folder mkdir $folder/data mkdir $folder/data/rules cd $folder/data/rules wget https://kprule.com/koolproxy.txt wget https://kprule.com/kp.dat wget https://kprule.com/daily.txt wget https://kprule.com/user.txt cd $folder wget -O koolproxy https://koolproxy.com/downloads/x86_64 chmod +x koolproxy fi
if [ -d "$folder" ]; then pkill -9 koolproxy cd $folder/data/rules rm koolproxy.txt kp.dat daily.txt wget https://kprule.com/koolproxy.txt wget https://kprule.com/kp.dat wget https://kprule.com/daily.txt cd $folder rm koolproxy wget -O koolproxy https://koolproxy.com/downloads/x86_64 chmod +x koolproxy fi echo "1" > /proc/sys/net/ipv4/ip_forward iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3000 cd $folder ./koolproxy > $folder/data/koolproxy.log 2>&1 &
|