OpenClash: sync with upstram source
This commit is contained in:
parent
cfdc7c5e11
commit
ac3ceb904d
@ -100,63 +100,55 @@ fake_block() {
|
||||
|
||||
yml_check()
|
||||
{
|
||||
#创建启动备份
|
||||
#替换tab
|
||||
sed -i 's/\t/ /g' "$3" 2>/dev/null
|
||||
|
||||
#检查关键字避免后续操作出错
|
||||
#proxies
|
||||
sed -i "/^ \{0,\}\'Proxy\':/c\Proxy:" "$3" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"Proxy\":/c\Proxy:' "$3" 2>/dev/null
|
||||
sed -i "/^ \{1,\}Proxy:/c\Proxy:" "$3" 2>/dev/null
|
||||
[ -z "$(grep "^Proxy:" "$CFG_FILE")" ] && {
|
||||
sed -i "s/^\'proxies\':/Proxy:/" "$CFG_FILE" 2>/dev/null
|
||||
sed -i 's/^\"proxies\":/Proxy:/' "$CFG_FILE" 2>/dev/null
|
||||
sed -i "s/^proxies:/Proxy:/" "$CFG_FILE" 2>/dev/null
|
||||
}
|
||||
|
||||
#proxy-providers
|
||||
sed -i "/^ \{0,\}\'proxy-provider\':/c\proxy-provider:" "$3" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"proxy-provider\":/c\proxy-provider:' "$3" 2>/dev/null
|
||||
sed -i "/^ \{1,\}proxy-provider:/c\proxy-provider:" "$3" 2>/dev/null
|
||||
sed -i "/^ \{0,\}\'proxy-providers\':/c\proxy-provider:" "$3" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"proxy-providers\":/c\proxy-provider:' "$3" 2>/dev/null
|
||||
sed -i "/^ \{0,\}proxy-providers:/c\proxy-provider:" "$3" 2>/dev/null
|
||||
|
||||
#proxy-groups
|
||||
sed -i "/^ \{0,\}\'Proxy Group\':/c\Proxy Group:" "$3" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"Proxy Group\":/c\Proxy Group:' "$3" 2>/dev/null
|
||||
sed -i "/^ \{1,\}Proxy Group:/c\Proxy Group:" "$3" 2>/dev/null
|
||||
sed -i "/^ \{0,\}\'proxy-groups\':/c\Proxy Group:" "$3" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"proxy-groups\":/c\Proxy Group:' "$3" 2>/dev/null
|
||||
sed -i "/^ \{0,\}proxy-groups:/c\Proxy Group:" "$3" 2>/dev/null
|
||||
|
||||
#rules
|
||||
sed -i "/^ \{0,\}\'Rule\':/c\Rule:" "$3" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"Rule\":/c\Rule:' "$3" 2>/dev/null
|
||||
sed -i "/^ \{1,\}Rule:/c\Rule:" "$3" 2>/dev/null
|
||||
sed -i "/^ \{0,\}\'rules\':/c\Rule:" "$3" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"rules\":/c\Rule:' "$3" 2>/dev/null
|
||||
sed -i "/^ \{0,\}rules:/c\Rule:" "$3" 2>/dev/null
|
||||
|
||||
sed -i "/^ \{0,\}\'dns\':/c\dns:" "$3" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"dns\":/c\dns:' "$3" 2>/dev/null
|
||||
sed -i "/^ \{1,\}dns:/c\dns:" "$3" 2>/dev/null
|
||||
|
||||
#创建启动备份
|
||||
cp "$3" "$5"
|
||||
|
||||
#创建原始备份
|
||||
if [ ! -f "$4" ]; then
|
||||
cp "$3" "$4"
|
||||
fi
|
||||
|
||||
#替换tab
|
||||
sed -i 's/\t/ /g' "$3" 2>/dev/null
|
||||
|
||||
#检查关键字避免后续操作出错
|
||||
|
||||
[ ! -z "$(grep "^ \{0,\}'Proxy':" "$3")" ] || [ ! -z "$(grep '^ \{0,\}"Proxy":' "$3")" ] && {
|
||||
sed -i "/^ \{0,\}\'Proxy\'/c\Proxy:" "$3"
|
||||
sed -i '/^ \{0,\}\"Proxy\":/c\Proxy:' "$3"
|
||||
}
|
||||
|
||||
[ ! -z "$(grep "^ \{0,\}'proxy-provider':" "$3")" ] || [ ! -z "$(grep '^ \{0,\}"proxy-provider":' "$3")" ] && {
|
||||
sed -i "/^ \{0,\}\'proxy-provider\'/c\proxy-provider:" "$3"
|
||||
sed -i '/^ \{0,\}\"proxy-provider\":/c\proxy-provider:' "$3"
|
||||
}
|
||||
|
||||
[ ! -z "$(grep "^ \{0,\}'Proxy Group':" "$3")" ] || [ ! -z "$(grep '^ \{0,\}"Proxy Group":' "$3")" ] && {
|
||||
sed -i "/^ \{0,\}\'Proxy Group\'/c\Proxy Group:" "$3"
|
||||
sed -i '/^ \{0,\}\"Proxy Group\":/c\Proxy Group:' "$3"
|
||||
}
|
||||
|
||||
[ ! -z "$(grep "^ \{0,\}'Rule':" "$3")" ] || [ ! -z "$(grep '^ \{0,\}"Rule":' "$3")" ] && {
|
||||
sed -i "/^ \{0,\}\'Rule\'/c\Rule:" "$3"
|
||||
sed -i '/^ \{0,\}\"Rule\":/c\Rule:' "$3"
|
||||
}
|
||||
|
||||
[ ! -z "$(grep "^ \{0,\}'dns':" "$3")" ] || [ ! -z "$(grep '^ \{0,\}"dns":' "$3")" ] && {
|
||||
sed -i "/^ \{0,\}\'dns\'/c\dns:" "$3"
|
||||
sed -i '/^ \{0,\}\"dns\":/c\dns:' "$3"
|
||||
}
|
||||
|
||||
[ ! -z "$(grep "^ \{1,\}Proxy:" "$3")" ] && {
|
||||
sed -i "/^ \{1,\}Proxy:/c\Proxy:" "$3"
|
||||
}
|
||||
|
||||
[ ! -z "$(grep "^ \{1,\}proxy-provider:" "$3")" ] && {
|
||||
sed -i "/^ \{1,\}proxy-provider:/c\proxy-provider:" "$3"
|
||||
}
|
||||
|
||||
[ ! -z "$(grep "^ \{1,\}Proxy Group:" "$3")" ] && {
|
||||
sed -i "/^ \{1,\}Proxy Group:/c\Proxy Group:" "$3"
|
||||
}
|
||||
|
||||
[ ! -z "$(grep "^ \{1,\}Rule:" "$3")" ] && {
|
||||
sed -i "/^ \{1,\}Rule:/c\Rule:" "$3"
|
||||
}
|
||||
|
||||
[ ! -z "$(grep "^ \{1,\}dns:" "$3")" ] && {
|
||||
sed -i "/^ \{1,\}dns:/c\dns:" "$3"
|
||||
}
|
||||
|
||||
#位置检查
|
||||
proxy_len=$(sed -n '/^Proxy:/=' "$3" 2>/dev/null)
|
||||
@ -688,8 +680,8 @@ if [ "$enable" -eq 1 ] && [ -f "$CONFIG_FILE" ]; then
|
||||
socks_port=$(uci get openclash.config.socks_port 2>/dev/null)
|
||||
enable_redirect_dns=$(uci get openclash.config.enable_redirect_dns 2>/dev/null)
|
||||
lan_ip=$(uci get network.lan.ipaddr 2>/dev/null |awk -F '/' '{print $1}' 2>/dev/null)
|
||||
wan_ip4=$(ubus call network.interface.wan status 2>/dev/null | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' 2>/dev/null)
|
||||
lan_ip6=$(uci get network.lan.ip6addr 2>/dev/null)
|
||||
wan_ip4=$(ifconfig | grep 'inet addr' | awk '{print $2}' | cut -d: -f2 2>/dev/null)
|
||||
lan_ip6=$(ifconfig | grep 'inet6 addr' | awk '{print $3}' 2>/dev/null)
|
||||
direct_dns=$(uci get openclash.config.direct_dns 2>/dev/null)
|
||||
disable_masq_cache=$(uci get openclash.config.disable_masq_cache 2>/dev/null)
|
||||
log_level=$(uci get openclash.config.log_level 2>/dev/null)
|
||||
@ -762,6 +754,8 @@ cat > "/var/etc/openclash.include" <<-EOF
|
||||
EOF
|
||||
iptables -t nat -I PREROUTING -p tcp --dport 53 -j ACCEPT
|
||||
if [ -z "$en_mode_tun" ]; then
|
||||
|
||||
#tcp
|
||||
iptables -t nat -N openclash
|
||||
iptables -t nat -A openclash -d 0.0.0.0/8 -j RETURN
|
||||
iptables -t nat -A openclash -d 10.0.0.0/8 -j RETURN
|
||||
@ -772,19 +766,53 @@ EOF
|
||||
iptables -t nat -A openclash -d 224.0.0.0/4 -j RETURN
|
||||
iptables -t nat -A openclash -d 240.0.0.0/4 -j RETURN
|
||||
if [ ! -z "$wan_ip4" ]; then
|
||||
iptables -t nat -A openclash -d "$wan_ip4" -j RETURN
|
||||
for wan_ip4s in $wan_ip4; do
|
||||
iptables -t nat -A openclash -d "$wan_ip4s" -j RETURN 2>/dev/null
|
||||
done
|
||||
fi
|
||||
|
||||
iptables -t nat -A openclash -p tcp -j REDIRECT --to-ports "$proxy_port"
|
||||
iptables -t nat -A PREROUTING -p tcp -j openclash
|
||||
|
||||
#udp
|
||||
ip rule add fwmark 1 table 100
|
||||
ip route add local default dev lo table 100
|
||||
iptables -t mangle -N openclash
|
||||
iptables -t mangle -A openclash -d 0.0.0.0/8 -j RETURN
|
||||
iptables -t mangle -A openclash -d 10.0.0.0/8 -j RETURN
|
||||
iptables -t mangle -A openclash -d 127.0.0.0/8 -j RETURN
|
||||
iptables -t mangle -A openclash -d 169.254.0.0/16 -j RETURN
|
||||
iptables -t mangle -A openclash -d 172.16.0.0/12 -j RETURN
|
||||
iptables -t mangle -A openclash -d 192.168.0.0/16 -j RETURN
|
||||
iptables -t mangle -A openclash -d 224.0.0.0/4 -j RETURN
|
||||
iptables -t mangle -A openclash -d 240.0.0.0/4 -j RETURN
|
||||
if [ ! -z "$wan_ip4" ]; then
|
||||
for wan_ip4s in $wan_ip4; do
|
||||
iptables -t mangle -A openclash -d "$wan_ip4s" -j RETURN 2>/dev/null
|
||||
done
|
||||
fi
|
||||
|
||||
iptables -t mangle -A openclash -p udp -j TPROXY --on-port "$proxy_port" --tproxy-mark 1
|
||||
iptables -t mangle -A PREROUTING -p udp -j openclash
|
||||
|
||||
if [ "$en_mode" = "fake-ip" ]; then
|
||||
iptables -t nat -A OUTPUT -p tcp -d 198.18.0.0/16 -j REDIRECT --to-ports "$proxy_port"
|
||||
iptables -t mangle -A OUTPUT -p udp -d 198.18.0.0/16 -j MARK --set-mark 1
|
||||
fi
|
||||
|
||||
if [ "$ipv6_enable" -eq 1 ]; then
|
||||
ip6tables -t nat -N openclash
|
||||
ip6tables -t mangle -N openclash
|
||||
if [ ! -z "$lan_ip6" ]; then
|
||||
for lan_ip6s in $lan_ip6; do
|
||||
ip6tables -t nat -A openclash -d "$lan_ip6s" -j RETURN 2>/dev/null
|
||||
ip6tables -t mangle -A openclash -d "$lan_ip6s" -j RETURN 2>/dev/null
|
||||
done
|
||||
fi
|
||||
ip6tables -t nat -A openclash -p tcp -j REDIRECT --to-ports "$proxy_port"
|
||||
ip6tables -t nat -A PREROUTING -p tcp -j openclash
|
||||
|
||||
ip6tables -t mangle -A openclash -p udp -j TPROXY --on-port "$proxy_port" --tproxy-mark 1
|
||||
ip6tables -t mangle -A PREROUTING -p udp -j openclash
|
||||
fi
|
||||
else
|
||||
#TUN模式
|
||||
@ -796,7 +824,11 @@ EOF
|
||||
ipset add localnetwork 224.0.0.0/4
|
||||
ipset add localnetwork 240.0.0.0/4
|
||||
ipset add localnetwork 172.16.0.0/12
|
||||
ipset add localnetwork "$wan_ip4"
|
||||
if [ ! -z "$wan_ip4" ]; then
|
||||
for wan_ip4s in $wan_ip4; do
|
||||
ipset add localnetwork "$wan_ip4s" 2>/dev/null
|
||||
done
|
||||
fi
|
||||
#启动TUN
|
||||
if [ "$en_mode_tun" = "2" ]; then
|
||||
ip tuntap add user root mode tun clash0
|
||||
@ -822,9 +854,9 @@ EOF
|
||||
iptables -t mangle -I OUTPUT -j openclash
|
||||
iptables -t mangle -I PREROUTING -m set ! --match-set localnetwork dst -j MARK --set-mark "$PROXY_FWMARK"
|
||||
#ipv6
|
||||
if [ "$ipv6_enable" -eq 1 ]; then
|
||||
ip6tables -t mangle -I PREROUTING -j MARK --set-mark "$PROXY_FWMARK"
|
||||
fi
|
||||
#if [ "$ipv6_enable" -eq 1 ]; then
|
||||
#ip6tables -t mangle -I PREROUTING -j MARK --set-mark "$PROXY_FWMARK"
|
||||
#fi
|
||||
fi
|
||||
|
||||
echo "第九步: 重启 Dnsmasq 程序..." >$START_LOG
|
||||
@ -931,16 +963,33 @@ stop()
|
||||
rm -rf /var/etc/openclash.include 2>/dev/null
|
||||
|
||||
#ipv4
|
||||
|
||||
ip rule del fwmark 1 table 100 >/dev/null 2>&1
|
||||
ip route del local default dev lo table 100 >/dev/null 2>&1
|
||||
|
||||
iptables -t mangle -F openclash >/dev/null 2>&1
|
||||
iptables -t mangle -D PREROUTING -p udp -j openclash >/dev/null 2>&1
|
||||
iptables -t mangle -X openclash >/dev/null 2>&1
|
||||
|
||||
iptables -t nat -F openclash >/dev/null 2>&1
|
||||
iptables -t nat -D PREROUTING -p tcp -j openclash >/dev/null 2>&1
|
||||
iptables -t nat -X openclash >/dev/null 2>&1
|
||||
|
||||
out_lines=$(iptables -nvL OUTPUT -t mangle |sed 1,2d |sed -n '/198.18.0.0\/16/=' 2>/dev/null |sort -rn)
|
||||
for out_line in $out_lines; do
|
||||
iptables -t mangle -D OUTPUT "$out_line" >/dev/null 2>&1
|
||||
done
|
||||
|
||||
out_lines=$(iptables -nvL OUTPUT -t nat |sed 1,2d |sed -n '/198.18.0.0\/16/=' 2>/dev/null |sort -rn)
|
||||
for out_line in $out_lines; do
|
||||
iptables -t nat -D OUTPUT "$out_line" >/dev/null 2>&1
|
||||
done
|
||||
|
||||
#ipv6
|
||||
ip6tables -t mangle -F openclash >/dev/null 2>&1
|
||||
ip6tables -t mangle -D PREROUTING -p udp -j openclash >/dev/null 2>&1
|
||||
ip6tables -t mangle -X openclash >/dev/null 2>&1
|
||||
|
||||
ip6tables -t nat -F openclash >/dev/null 2>&1
|
||||
ip6tables -t nat -D PREROUTING -p tcp -j openclash >/dev/null 2>&1
|
||||
ip6tables -t nat -X openclash >/dev/null 2>&1
|
||||
|
||||
@ -394,6 +394,7 @@ Rule:
|
||||
- DOMAIN-SUFFIX,tvb.com,GlobalMedia
|
||||
# > Netflix
|
||||
# USER-AGENT,Argo*,GlobalMedia
|
||||
- DOMAIN-SUFFIX,fast.com,GlobalMedia
|
||||
- DOMAIN-SUFFIX,netflix.com,GlobalMedia
|
||||
- DOMAIN-SUFFIX,netflix.net,GlobalMedia
|
||||
- DOMAIN-SUFFIX,nflxext.com,GlobalMedia
|
||||
@ -1171,14 +1172,18 @@ Rule:
|
||||
# > Tencent
|
||||
# USER-AGENT,MicroMessenger%20Client,DIRECT
|
||||
# USER-AGENT,WeChat*,DIRECT
|
||||
# USER-AGENT,%E4%BC%81%E4%B8%9A%E5%BE%AE%E4%BF%A1*,DIRECT
|
||||
- DOMAIN-SUFFIX,gtimg.com,DIRECT
|
||||
- DOMAIN-SUFFIX,idqqimg.com,DIRECT
|
||||
- DOMAIN-SUFFIX,igamecj.com,DIRECT
|
||||
- DOMAIN-SUFFIX,myapp.com,DIRECT
|
||||
- DOMAIN-SUFFIX,myqcloud.com,DIRECT
|
||||
- DOMAIN-SUFFIX,qq.com,DIRECT
|
||||
- DOMAIN-SUFFIX,servicewechat.com,DIRECT
|
||||
- DOMAIN-SUFFIX,tencent.com,DIRECT
|
||||
- DOMAIN-SUFFIX,tencent-cloud.net,DIRECT
|
||||
- DOMAIN-SUFFIX,tenpay.com,DIRECT
|
||||
- DOMAIN,file-igamecj.akamaized.net,DIRECT
|
||||
# > YYeTs
|
||||
# USER-AGENT,YYeTs*,DIRECT
|
||||
- DOMAIN-SUFFIX,jstucdn.com,DIRECT
|
||||
|
||||
@ -72,23 +72,23 @@ dns: # 如订阅配置无包括此项的所有DNS设置,OpenClash将自动添
|
||||
# 以上设置您可直接覆盖到配置文件,无需更改
|
||||
# Openclash 不会对下方服务器设置进行任何更改,请确保设置正确
|
||||
|
||||
proxy-provider: # 代理集设置,此部分与Proxy两者不能同时删除
|
||||
pro:
|
||||
type: http
|
||||
path: ./proxy_provider/pro.yaml
|
||||
url: https://xxx
|
||||
interval: 3600
|
||||
health-check:
|
||||
enable: true
|
||||
url: http://www.gstatic.com/generate_204
|
||||
interval: 300
|
||||
iplc:
|
||||
type: file
|
||||
path: ./proxy_provider/iplc.yaml
|
||||
health-check:
|
||||
enable: true
|
||||
url: http://www.gstatic.com/generate_204
|
||||
interval: 300
|
||||
#proxy-provider: # 代理集设置,此部分与Proxy两者不能同时删除
|
||||
# pro:
|
||||
# type: http
|
||||
# path: ./proxy_provider/pro.yaml
|
||||
# url: https://xxx
|
||||
# interval: 3600
|
||||
# health-check:
|
||||
# enable: true
|
||||
# url: http://www.gstatic.com/generate_204
|
||||
# interval: 300
|
||||
# iplc:
|
||||
# type: file
|
||||
# path: ./proxy_provider/iplc.yaml
|
||||
# health-check:
|
||||
# enable: true
|
||||
# url: http://www.gstatic.com/generate_204
|
||||
# interval: 300
|
||||
|
||||
Proxy: # 节点设置,此部分与proxy-provider两者不能同时删除
|
||||
|
||||
|
||||
@ -865,7 +865,6 @@ Rule:
|
||||
- DOMAIN-SUFFIX,ab-gb.mgid.com,AdBlock
|
||||
- DOMAIN-SUFFIX,abtest.mistat.xiaomi.com,AdBlock
|
||||
- DOMAIN-SUFFIX,ac.atpanel.com,AdBlock
|
||||
- DOMAIN-SUFFIX,ac.mmstat.com,AdBlock
|
||||
- DOMAIN-SUFFIX,ac2.msn.com,AdBlock
|
||||
- DOMAIN-SUFFIX,ac3.msn.com,AdBlock
|
||||
- DOMAIN-SUFFIX,acasys88.cn,AdBlock
|
||||
@ -1525,7 +1524,6 @@ Rule:
|
||||
- DOMAIN-SUFFIX,api.ijunhai.com,AdBlock
|
||||
- DOMAIN-SUFFIX,api.itaoxiaoshuo.com,AdBlock
|
||||
- DOMAIN-SUFFIX,api.joybj.com,AdBlock
|
||||
- DOMAIN-SUFFIX,api.jr.mi.com,AdBlock
|
||||
- DOMAIN-SUFFIX,api.ketedata.com,AdBlock
|
||||
- DOMAIN-SUFFIX,api.koudaikj.com,AdBlock
|
||||
- DOMAIN-SUFFIX,api.leadbolt.net,AdBlock
|
||||
@ -1718,7 +1716,6 @@ Rule:
|
||||
- DOMAIN-SUFFIX,b.aowugame.com,AdBlock
|
||||
- DOMAIN-SUFFIX,b.babylon.com,AdBlock
|
||||
- DOMAIN-SUFFIX,b.baiy.net,AdBlock
|
||||
- DOMAIN-SUFFIX,b.bdstatic.com,AdBlock
|
||||
- DOMAIN-SUFFIX,b.bst.126.net,AdBlock
|
||||
- DOMAIN-SUFFIX,b.clkservice.youdao.com,AdBlock
|
||||
- DOMAIN-SUFFIX,b.code.tanwanyx.com,AdBlock
|
||||
@ -3737,7 +3734,6 @@ Rule:
|
||||
- DOMAIN-SUFFIX,go.gotourl.xyz,AdBlock
|
||||
- DOMAIN-SUFFIX,go.gotourls.bid,AdBlock
|
||||
- DOMAIN-SUFFIX,go.hangzhou.com.cn,AdBlock
|
||||
- DOMAIN-SUFFIX,go.mmstat.com,AdBlock
|
||||
- DOMAIN-SUFFIX,go.onclasrv.com,AdBlock
|
||||
- DOMAIN-SUFFIX,go.util.zlibs.com,AdBlock
|
||||
- DOMAIN-SUFFIX,godloveme.cn,AdBlock
|
||||
@ -3799,7 +3795,6 @@ Rule:
|
||||
- DOMAIN-SUFFIX,gw6.push.mcp.weibo.cn,AdBlock
|
||||
- DOMAIN-SUFFIX,gw630.com,AdBlock
|
||||
- DOMAIN-SUFFIX,gx38.cn,AdBlock
|
||||
- DOMAIN-SUFFIX,gxb.mmstat.com,AdBlock
|
||||
- DOMAIN-SUFFIX,gxdhgb.com,AdBlock
|
||||
- DOMAIN-SUFFIX,gxe.husky.sogou.com,AdBlock
|
||||
- DOMAIN-SUFFIX,gyca9f.dahuangcheng.cn,AdBlock
|
||||
@ -3987,7 +3982,6 @@ Rule:
|
||||
- DOMAIN-SUFFIX,hytgj.com,AdBlock
|
||||
- DOMAIN-SUFFIX,hyz86.com,AdBlock
|
||||
- DOMAIN-SUFFIX,hz.miercn.com,AdBlock
|
||||
- DOMAIN-SUFFIX,hz.mmstat.com,AdBlock
|
||||
- DOMAIN-SUFFIX,hz.shouyoutv.com,AdBlock
|
||||
- DOMAIN-SUFFIX,hzaibi.com,AdBlock
|
||||
- DOMAIN-SUFFIX,hzdmacore.kejet.net,AdBlock
|
||||
@ -5452,7 +5446,6 @@ Rule:
|
||||
- DOMAIN-SUFFIX,mmcc.yxlady.com,AdBlock
|
||||
- DOMAIN-SUFFIX,mmg.aty.cp45.ott.cibntv.net,AdBlock
|
||||
- DOMAIN-SUFFIX,mmg.aty.snmsohu.aisee.tv,AdBlock
|
||||
- DOMAIN-SUFFIX,mmstat.com,AdBlock
|
||||
- DOMAIN-SUFFIX,mng-ads.com,AdBlock
|
||||
- DOMAIN-SUFFIX,mnkan.com,AdBlock
|
||||
- DOMAIN-SUFFIX,mnwan.com,AdBlock
|
||||
@ -5846,7 +5839,6 @@ Rule:
|
||||
- DOMAIN-SUFFIX,p215223.inclk.com,AdBlock
|
||||
- DOMAIN-SUFFIX,p215223.mycdn2.co,AdBlock
|
||||
- DOMAIN-SUFFIX,p2pmid.baofeng.com,AdBlock
|
||||
- DOMAIN-SUFFIX,p3p.mmstat.com,AdBlock
|
||||
- DOMAIN-SUFFIX,p3p.sogou.com,AdBlock
|
||||
- DOMAIN-SUFFIX,p3p.yahoo.com,AdBlock
|
||||
- DOMAIN-SUFFIX,p3tt.com,AdBlock
|
||||
@ -6354,7 +6346,6 @@ Rule:
|
||||
- DOMAIN-SUFFIX,res.dxpmedia.com,AdBlock
|
||||
- DOMAIN-SUFFIX,res.icast.cn,AdBlock
|
||||
- DOMAIN-SUFFIX,res.ipingke.com,AdBlock
|
||||
- DOMAIN-SUFFIX,res.mmstat.com,AdBlock
|
||||
- DOMAIN-SUFFIX,res.qhupdate.com,AdBlock
|
||||
- DOMAIN-SUFFIX,res3.feedsportal.com,AdBlock
|
||||
- DOMAIN-SUFFIX,rescn.u3.ucweb.com,AdBlock
|
||||
@ -7666,7 +7657,6 @@ Rule:
|
||||
- DOMAIN-SUFFIX,wgie.0z5jn.cn,AdBlock
|
||||
- DOMAIN-SUFFIX,wgnlz.com,AdBlock
|
||||
- DOMAIN-SUFFIX,wgnmp.com,AdBlock
|
||||
- DOMAIN-SUFFIX,wgo.mmstat.com,AdBlock
|
||||
- DOMAIN-SUFFIX,whafwl.com,AdBlock
|
||||
- DOMAIN-SUFFIX,whalecloud.com,AdBlock
|
||||
- DOMAIN-SUFFIX,whcrdz.com,AdBlock
|
||||
@ -8106,7 +8096,6 @@ Rule:
|
||||
- DOMAIN-SUFFIX,ysjwj.com,AdBlock
|
||||
- DOMAIN-SUFFIX,ysm.hauchi.com.tw,AdBlock
|
||||
- DOMAIN-SUFFIX,ysm.yahoo.com,AdBlock
|
||||
- DOMAIN-SUFFIX,yt.mmstat.com,AdBlock
|
||||
- DOMAIN-SUFFIX,yt-adp.nosdn.127.net,AdBlock
|
||||
- DOMAIN-SUFFIX,ytapi1.nagezan.net,AdBlock
|
||||
- DOMAIN-SUFFIX,ytdksb.com,AdBlock
|
||||
@ -8487,6 +8476,7 @@ Rule:
|
||||
# - USER-AGENT,InstantVideo.US*,GlobalTV
|
||||
# - USER-AGENT,Prime%20Video*,GlobalTV
|
||||
- DOMAIN-SUFFIX,aiv-cdn.net,GlobalTV
|
||||
- DOMAIN-SUFFIX,amazonaws.co.uk,GlobalTV
|
||||
- DOMAIN-SUFFIX,amazonaws.com,GlobalTV
|
||||
- DOMAIN-SUFFIX,amazonvideo.com,GlobalTV
|
||||
- DOMAIN-SUFFIX,llnwd.net,GlobalTV
|
||||
@ -8517,6 +8507,14 @@ Rule:
|
||||
# - USER-AGENT,TwDramas*,GlobalTV
|
||||
- DOMAIN-SUFFIX,chocotv.com.tw,GlobalTV
|
||||
|
||||
# > DAZN
|
||||
- DOMAIN-SUFFIX,d151l6v8er5bdm.cloudfront.net,GlobalTV
|
||||
- DOMAIN-SUFFIX,dazn.com,GlobalTV
|
||||
- DOMAIN-SUFFIX,dazn-api.com,GlobalTV
|
||||
- DOMAIN-SUFFIX,dazndn.com,GlobalTV
|
||||
- DOMAIN-SUFFIX,indazn.com,GlobalTV
|
||||
- DOMAIN-SUFFIX,intercom.io,GlobalTV
|
||||
|
||||
# > Disney Plus
|
||||
# - USER-AGENT,Disney*,GlobalTV
|
||||
- DOMAIN,cdn.registerdisney.go.com,GlobalTV
|
||||
@ -8595,6 +8593,8 @@ Rule:
|
||||
|
||||
# > SoundCloud
|
||||
# - USER-AGENT,SoundCloud*,GlobalTV
|
||||
- DOMAIN-SUFFIX,sndcdn.com,GlobalTV
|
||||
- DOMAIN-SUFFIX,soundcloud.com,GlobalTV
|
||||
|
||||
# > viuTV
|
||||
- DOMAIN-SUFFIX,cloudfront.net,GlobalTV
|
||||
@ -8616,6 +8616,21 @@ Rule:
|
||||
- DOMAIN-SUFFIX,nflximg.net,Netflix
|
||||
- DOMAIN-SUFFIX,nflxso.net,Netflix
|
||||
- DOMAIN-SUFFIX,nflxvideo.net,Netflix
|
||||
- IP-CIDR,8.41.4.0/24,Netflix
|
||||
- IP-CIDR,23.246.0.0/18,Netflix
|
||||
- IP-CIDR,37.77.184.0/21,Netflix
|
||||
- IP-CIDR,45.57.0.0/17,Netflix
|
||||
- IP-CIDR,64.120.128.0/17,Netflix
|
||||
- IP-CIDR,66.197.128.0/17,Netflix
|
||||
- IP-CIDR,69.53.224.0/19,Netflix
|
||||
- IP-CIDR,108.175.32.0/20,Netflix
|
||||
- IP-CIDR,185.2.220.0/22,Netflix
|
||||
- IP-CIDR,185.9.188.0/22,Netflix
|
||||
- IP-CIDR,192.173.64.0/18,Netflix
|
||||
- IP-CIDR,198.38.96.0/19,Netflix
|
||||
- IP-CIDR,198.45.48.0/20,Netflix
|
||||
- IP-CIDR,207.45.72.0/22,Netflix
|
||||
- IP-CIDR,208.75.76.0/22,Netflix
|
||||
|
||||
# > Spotify
|
||||
# - USER-AGENT,*Spotify*,Spotify
|
||||
@ -8661,14 +8676,12 @@ Rule:
|
||||
|
||||
|
||||
|
||||
# > Dler Cloud
|
||||
- DOMAIN,dler.cloud,DIRECT
|
||||
|
||||
# > Google
|
||||
- DOMAIN-KEYWORD,mtalk.google.com,DIRECT
|
||||
- DOMAIN,safebrowsing.googleapis.com,DIRECT
|
||||
|
||||
# > Steam
|
||||
# - USER-AGENT,Steam*,DIRECT
|
||||
- DOMAIN-SUFFIX,steamcontent.com,DIRECT
|
||||
|
||||
# > Private Tracker
|
||||
@ -8706,9 +8719,6 @@ Rule:
|
||||
# - URL-REGEX,(.+\.|^)(360|so|qihoo|360safe|qhimg|360totalsecurity|yunpan)\.(cn|com),DIRECT
|
||||
# - URL-REGEX,(.+\.)?(torrent|announce\.php\?passkey=|tracker|BitTorrent|bt_key|ed2k|find_node|get_peers|info_hash|magnet:|peer_id=|sandai|Thunder|XLLiveUD|xunlei)(\..+)?,DIRECT
|
||||
|
||||
- DOMAIN-SUFFIX,smtp,DIRECT,no-resolve
|
||||
- DOMAIN-SUFFIX,local,DIRECT,no-resolve
|
||||
|
||||
|
||||
|
||||
# > Line
|
||||
@ -8722,7 +8732,13 @@ Rule:
|
||||
|
||||
# > Microsoft
|
||||
# - USER-AGENT,OneDrive*,Proxy
|
||||
- DOMAIN-SUFFIX,onedrive.live.com,Proxy
|
||||
- DOMAIN-KEYWORD,microsoft,Proxy
|
||||
- DOMAIN-KEYWORD,onedrive,Proxy
|
||||
- DOMAIN-SUFFIX,azure.com,Proxy
|
||||
- DOMAIN-SUFFIX,live.com,Proxy
|
||||
- DOMAIN-SUFFIX,live.net,Proxy
|
||||
- DOMAIN-SUFFIX,office.com,Proxy
|
||||
- DOMAIN-SUFFIX,office.net,Proxy
|
||||
- DOMAIN-SUFFIX,skype.com,Proxy
|
||||
|
||||
# > Spark
|
||||
@ -9037,7 +9053,6 @@ Rule:
|
||||
- DOMAIN-SUFFIX,nytstyle.com,Proxy
|
||||
- DOMAIN-SUFFIX,office365.com,Proxy
|
||||
- DOMAIN-SUFFIX,omnigroup.com,Proxy
|
||||
- DOMAIN-SUFFIX,onedrive.com,Proxy
|
||||
- DOMAIN-SUFFIX,onenote.com,Proxy
|
||||
- DOMAIN-SUFFIX,ooyala.com,Proxy
|
||||
- DOMAIN-SUFFIX,openvpn.net,Proxy
|
||||
@ -9280,6 +9295,7 @@ Rule:
|
||||
- DOMAIN-SUFFIX,wn.com,Proxy
|
||||
- DOMAIN-SUFFIX,wordpress.com,Proxy
|
||||
- DOMAIN-SUFFIX,workflow.is,Proxy
|
||||
- DOMAIN-SUFFIX,workflowy.com,Proxy
|
||||
- DOMAIN-SUFFIX,worldcat.org,Proxy
|
||||
- DOMAIN-SUFFIX,wow.com,Proxy
|
||||
- DOMAIN-SUFFIX,wp.com,Proxy
|
||||
@ -9458,14 +9474,9 @@ Rule:
|
||||
- DOMAIN-SUFFIX,blizzard.com,Domestic
|
||||
|
||||
# > Microsoft
|
||||
- DOMAIN-KEYWORD,microsoft,Domestic
|
||||
- DOMAIN-SUFFIX,azure.com,Domestic
|
||||
- DOMAIN-SUFFIX,azure.cn,Domestic
|
||||
- DOMAIN-SUFFIX,hotmail.com,Domestic
|
||||
- DOMAIN-SUFFIX,live.com,Domestic
|
||||
- DOMAIN-SUFFIX,live.net,Domestic
|
||||
- DOMAIN-SUFFIX,msn.com,Domestic
|
||||
- DOMAIN-SUFFIX,office.com,Domestic
|
||||
- DOMAIN-SUFFIX,office.net,Domestic
|
||||
- DOMAIN-SUFFIX,outlook.com,Domestic
|
||||
- DOMAIN-SUFFIX,windows.com,Domestic
|
||||
- DOMAIN-SUFFIX,windows.net,Domestic
|
||||
@ -9591,7 +9602,6 @@ Rule:
|
||||
- DOMAIN-SUFFIX,iciba.com,Domestic
|
||||
- DOMAIN-SUFFIX,ifeng.com,Domestic
|
||||
- DOMAIN-SUFFIX,ifengimg.com,Domestic
|
||||
- DOMAIN-SUFFIX,images.unsplash.com,Domestic
|
||||
- DOMAIN-SUFFIX,images-amazon.com,Domestic
|
||||
- DOMAIN-SUFFIX,img4me.com,Domestic
|
||||
- DOMAIN-SUFFIX,ipify.org,Domestic
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -31,9 +31,21 @@ function config_check(CONFIG_FILE)
|
||||
local proxy,group,rule
|
||||
if yaml then
|
||||
proxy_provier = luci.sys.call(string.format('egrep "^ {0,}proxy-provider:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
if (proxy_provier ~= 0) then
|
||||
proxy_provier = luci.sys.call(string.format('egrep "^ {0,}proxy-providers:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
end
|
||||
proxy = luci.sys.call(string.format('egrep "^ {0,}Proxy:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
if (proxy ~= 0) then
|
||||
proxy = luci.sys.call(string.format('egrep "^ {0,}proxies:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
end
|
||||
group = luci.sys.call(string.format('egrep "^ {0,}Proxy Group:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
if (group ~= 0) then
|
||||
group = luci.sys.call(string.format('egrep "^ {0,}proxy-groups:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
end
|
||||
rule = luci.sys.call(string.format('egrep "^ {0,}Rule:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
if (rule ~= 0) then
|
||||
rule = luci.sys.call(string.format('egrep "^ {0,}rules:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
end
|
||||
end
|
||||
if yaml then
|
||||
if (proxy == 0) then
|
||||
@ -80,7 +92,6 @@ if string.sub(luci.sys.exec("uci get openclash.config.config_path"), 23, -2) ==
|
||||
else
|
||||
e[t].state=translate("Disable")
|
||||
end
|
||||
e[t].size=tostring(a.size)
|
||||
e[t].check=translate(config_check(CONFIG_FILE))
|
||||
end
|
||||
end
|
||||
|
||||
@ -23,6 +23,57 @@ function IsYmlFile(e)
|
||||
local e=string.lower(string.sub(e,-4,-1))
|
||||
return e == ".yml"
|
||||
end
|
||||
|
||||
function config_check(CONFIG_FILE)
|
||||
local yaml = fs.isfile(CONFIG_FILE)
|
||||
local proxy,group,rule
|
||||
if yaml then
|
||||
proxy_provier = luci.sys.call(string.format('egrep "^ {0,}proxy-provider:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
if (proxy_provier ~= 0) then
|
||||
proxy_provier = luci.sys.call(string.format('egrep "^ {0,}proxy-providers:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
end
|
||||
proxy = luci.sys.call(string.format('egrep "^ {0,}Proxy:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
if (proxy ~= 0) then
|
||||
proxy = luci.sys.call(string.format('egrep "^ {0,}proxies:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
end
|
||||
group = luci.sys.call(string.format('egrep "^ {0,}Proxy Group:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
if (group ~= 0) then
|
||||
group = luci.sys.call(string.format('egrep "^ {0,}proxy-groups:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
end
|
||||
rule = luci.sys.call(string.format('egrep "^ {0,}Rule:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
if (rule ~= 0) then
|
||||
rule = luci.sys.call(string.format('egrep "^ {0,}rules:" "%s" >/dev/null 2>&1',CONFIG_FILE))
|
||||
end
|
||||
end
|
||||
if yaml then
|
||||
if (proxy == 0) then
|
||||
proxy = ""
|
||||
else
|
||||
if (proxy_provier == 0) then
|
||||
proxy = ""
|
||||
else
|
||||
proxy = " - 代理服务器"
|
||||
end
|
||||
end
|
||||
if (group == 0) then
|
||||
group = ""
|
||||
else
|
||||
group = " - 策略组"
|
||||
end
|
||||
if (rule == 0) then
|
||||
rule = ""
|
||||
else
|
||||
rule = " - 规则"
|
||||
end
|
||||
if (proxy=="") and (group=="") and (rule=="") then
|
||||
return "Config Normal"
|
||||
else
|
||||
return proxy..group..rule.." - 部分异常"
|
||||
end
|
||||
elseif (yaml ~= 0) then
|
||||
return "配置文件不存在"
|
||||
end
|
||||
end
|
||||
|
||||
ful = SimpleForm("upload", translate("Config Manage"), nil)
|
||||
ful.reset = false
|
||||
@ -110,6 +161,7 @@ if a then
|
||||
e[t]={}
|
||||
e[t].name=fs.basename(o)
|
||||
BACKUP_FILE="/etc/openclash/backup/".. e[t].name
|
||||
CONFIG_FILE="/etc/openclash/config/".. e[t].name
|
||||
e[t].mtime=os.date("%Y-%m-%d %H:%M:%S",fs.mtime(BACKUP_FILE)) or os.date("%Y-%m-%d %H:%M:%S",a.mtime)
|
||||
if string.sub(luci.sys.exec("uci get openclash.config.config_path"), 23, -2) == e[t].name then
|
||||
e[t].state=translate("Enable")
|
||||
@ -117,21 +169,10 @@ else
|
||||
e[t].state=translate("Disable")
|
||||
end
|
||||
e[t].size=i(a.size)
|
||||
e[t].check=translate(config_check(CONFIG_FILE))
|
||||
e[t].remove=0
|
||||
e[t].enable=false
|
||||
end
|
||||
end
|
||||
|
||||
function IsYamlFile(e)
|
||||
e=e or""
|
||||
local e=string.lower(string.sub(e,-5,-1))
|
||||
return e == ".yaml"
|
||||
end
|
||||
function IsYmlFile(e)
|
||||
e=e or""
|
||||
local e=string.lower(string.sub(e,-4,-1))
|
||||
return e == ".yml"
|
||||
end
|
||||
|
||||
form=SimpleForm("config_file_list",translate("Config File List"))
|
||||
form.reset=false
|
||||
@ -142,6 +183,8 @@ st.template="openclash/cfg_check"
|
||||
nm=tb:option(DummyValue,"name",translate("Config Alias"))
|
||||
mt=tb:option(DummyValue,"mtime",translate("Update Time"))
|
||||
sz=tb:option(DummyValue,"size",translate("Size"))
|
||||
ck=tb:option(DummyValue,"check",translate("启动参数检查"))
|
||||
ck.template="openclash/cfg_check"
|
||||
|
||||
btnis=tb:option(Button,"switch",translate("Switch Config"))
|
||||
btnis.template="openclash/other_button"
|
||||
|
||||
@ -4,9 +4,15 @@ LAST_OPVER="/tmp/clash_last_version"
|
||||
LAST_VER=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |awk -F '-' '{print $1$2}' 2>/dev/null |awk -F '.' '{print $2$3}' 2>/dev/null)
|
||||
CLASH_VERF=$(/etc/openclash/clash -v 2>/dev/null)
|
||||
CLASH_VER=$(echo "$CLASH_VERF" 2>/dev/null |awk -F ' ' '{print $2}' 2>/dev/null |awk -F '-' '{print $1$2}' 2>/dev/null |awk -F '.' '{print $2$3}' 2>/dev/null)
|
||||
version_url="https://raw.githubusercontent.com/vernesong/OpenClash/master/core_version"
|
||||
HTTP_PORT=$(uci get openclash.config.http_port 2>/dev/null)
|
||||
PROXY_ADDR="127.0.0.1"
|
||||
VERSION_URL="https://raw.githubusercontent.com/vernesong/OpenClash/master/core_version"
|
||||
if [ "$CKTIME" != "$(grep "CheckTime" $LAST_OPVER 2>/dev/null |awk -F ':' '{print $2}')" ]; then
|
||||
curl -sL --connect-timeout 10 --retry 2 "$version_url" -o $LAST_OPVER >/dev/null 2>&1
|
||||
if pidof clash >/dev/null; then
|
||||
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT "$VERSION_URL" -o $LAST_OPVER >/dev/null 2>&1
|
||||
else
|
||||
curl -sL --connect-timeout 10 --retry 2 "$VERSION_URL" -o $LAST_OPVER >/dev/null 2>&1
|
||||
fi
|
||||
if [ "$?" -eq "0" ] && [ -s "$LAST_OPVER" ]; then
|
||||
echo "CheckTime:$CKTIME" >>$LAST_OPVER
|
||||
else
|
||||
|
||||
@ -7,14 +7,14 @@ START_LOG="/tmp/openclash_start.log"
|
||||
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
LOG_FILE="/tmp/openclash.log"
|
||||
CPU_MODEL=$(uci get openclash.config.core_version 2>/dev/null)
|
||||
http_port=$(uci get openclash.config.http_port 2>/dev/null)
|
||||
proxy_addr="127.0.0.1"
|
||||
HTTP_PORT=$(uci get openclash.config.http_port 2>/dev/null)
|
||||
PROXY_ADDR="127.0.0.1"
|
||||
|
||||
if [ "$(/etc/openclash/clash -v 2>/dev/null |awk -F ' ' '{print $2}')" != "$(sed -n 1p /tmp/clash_last_version 2>/dev/null)" ] || [ -z "$(/etc/openclash/clash -v 2>/dev/null |awk -F ' ' '{print $2}')" ] || [ ! -f /etc/openclash/clash ]; then
|
||||
if [ "$CPU_MODEL" != 0 ]; then
|
||||
echo "开始下载 OpenClash 内核..." >$START_LOG
|
||||
if [ ! -z "$(pidof clash|sed 's/$//g')" ]; then
|
||||
curl -sL --connect-timeout 10 --retry 2 -x http://$proxy_addr:$http_port https://github.com/vernesong/OpenClash/releases/download/Clash/clash-"$CPU_MODEL".tar.gz -o /tmp/clash.tar.gz >/dev/null 2>&1
|
||||
if pidof clash >/dev/null; then
|
||||
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT https://github.com/vernesong/OpenClash/releases/download/Clash/clash-"$CPU_MODEL".tar.gz -o /tmp/clash.tar.gz >/dev/null 2>&1
|
||||
else
|
||||
curl -sL --connect-timeout 10 --retry 2 https://github.com/vernesong/OpenClash/releases/download/Clash/clash-"$CPU_MODEL".tar.gz -o /tmp/clash.tar.gz >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
@ -10,7 +10,13 @@
|
||||
TMP_RULE_DIR="/tmp/$RULE_FILE_NAME"
|
||||
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
LOG_FILE="/tmp/openclash.log"
|
||||
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/FQrabbit/SSTap-Rule/master/rules/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" >/dev/null 2>&1
|
||||
HTTP_PORT=$(uci get openclash.config.http_port 2>/dev/null)
|
||||
PROXY_ADDR="127.0.0.1"
|
||||
if pidof clash >/dev/null; then
|
||||
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT https://raw.githubusercontent.com/FQrabbit/SSTap-Rule/master/rules/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" >/dev/null 2>&1
|
||||
else
|
||||
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/FQrabbit/SSTap-Rule/master/rules/"$DOWNLOAD_PATH" -o "$TMP_RULE_DIR" >/dev/null 2>&1
|
||||
fi
|
||||
if [ "$?" -eq "0" ] && [ "$(ls -l $TMP_RULE_DIR |awk '{print $5}')" -ne 0 ]; then
|
||||
cmp -s $TMP_RULE_DIR $RULE_FILE_DIR
|
||||
if [ "$?" -ne "0" ]; then
|
||||
|
||||
@ -3,47 +3,65 @@
|
||||
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
LOG_FILE="/tmp/openclash.log"
|
||||
echo "开始获取使用中的第三方规则名称..." >$START_LOG
|
||||
rule_source=$(uci get openclash.config.rule_source 2>/dev/null)
|
||||
RUlE_SOURCE=$(uci get openclash.config.rule_source 2>/dev/null)
|
||||
HTTP_PORT=$(uci get openclash.config.http_port 2>/dev/null)
|
||||
PROXY_ADDR="127.0.0.1"
|
||||
echo "开始下载使用中的第三方规则..." >$START_LOG
|
||||
if [ "$rule_source" = "lhie1" ]; then
|
||||
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/lhie1/Rules/master/Clash/Rule.yml -o /tmp/rules.yaml >/dev/null 2>&1
|
||||
if [ "$RUlE_SOURCE" = "lhie1" ]; then
|
||||
if pidof clash >/dev/null; then
|
||||
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT https://raw.githubusercontent.com/lhie1/Rules/master/Clash/Rule.yaml -o /tmp/rules.yaml >/dev/null 2>&1
|
||||
else
|
||||
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/lhie1/Rules/master/Clash/Rule.yaml -o /tmp/rules.yaml >/dev/null 2>&1
|
||||
fi
|
||||
sed -i '1i Rule:' /tmp/rules.yaml
|
||||
elif [ "$rule_source" = "ConnersHua" ]; then
|
||||
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/ConnersHua/Profiles/master/Clash/Pro.yaml -o /tmp/rules.yaml >/dev/null 2>&1
|
||||
sed -i -n '/^Rule:/,$p' /tmp/rules.yaml
|
||||
elif [ "$rule_source" = "ConnersHua_return" ]; then
|
||||
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/ConnersHua/Profiles/master/Clash/BacktoCN.yaml -o /tmp/rules.yaml >/dev/null 2>&1
|
||||
sed -i -n '/^Rule:/,$p' /tmp/rules.yaml
|
||||
elif [ "$RUlE_SOURCE" = "ConnersHua" ]; then
|
||||
if pidof clash >/dev/null; then
|
||||
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT https://raw.githubusercontent.com/ConnersHua/Profiles/master/Clash/Pro.yaml -o /tmp/rules.yaml >/dev/null 2>&1
|
||||
else
|
||||
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/ConnersHua/Profiles/master/Clash/Pro.yaml -o /tmp/rules.yaml >/dev/null 2>&1
|
||||
fi
|
||||
sed -i -n '/^Rule:/,$p' /tmp/rules.yaml 2>/dev/null
|
||||
sed -i -n '/^rules:/,$p' /tmp/rules.yaml 2>/dev/null
|
||||
sed -i "/^rules:/c\^Rule:" /tmp/rules.yaml 2>/dev/null
|
||||
elif [ "$RUlE_SOURCE" = "ConnersHua_return" ]; then
|
||||
if pidof clash >/dev/null; then
|
||||
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT https://raw.githubusercontent.com/ConnersHua/Profiles/master/Clash/BacktoCN.yaml -o /tmp/rules.yaml >/dev/null 2>&1
|
||||
else
|
||||
curl -sL --connect-timeout 10 --retry 2 https://raw.githubusercontent.com/ConnersHua/Profiles/master/Clash/BacktoCN.yaml -o /tmp/rules.yaml >/dev/null 2>&1
|
||||
fi
|
||||
sed -i -n '/^Rule:/,$p' /tmp/rules.yaml 2>/dev/null
|
||||
sed -i -n '/^rules:/,$p' /tmp/rules.yaml 2>/dev/null
|
||||
sed -i "/^rules:/c\^Rule:" /tmp/rules.yaml 2>/dev/null
|
||||
fi
|
||||
if [ "$?" -eq "0" ] && [ "$rule_source" != 0 ] && [ -s "/tmp/rules.yaml" ]; then
|
||||
if [ "$?" -eq "0" ] && [ "$RUlE_SOURCE" != 0 ] && [ -s "/tmp/rules.yaml" ]; then
|
||||
echo "下载成功,开始预处理规则文件..." >$START_LOG
|
||||
sed -i "/^Rule:/a\##source:${rule_source}" /tmp/rules.yaml >/dev/null 2>&1
|
||||
sed -i "/^Rule:/a\##source:${RUlE_SOURCE}" /tmp/rules.yaml >/dev/null 2>&1
|
||||
echo "检查下载的规则文件是否有更新..." >$START_LOG
|
||||
cmp -s /etc/openclash/"$rule_source".yaml /tmp/rules.yaml
|
||||
cmp -s /etc/openclash/"$RUlE_SOURCE".yaml /tmp/rules.yaml
|
||||
if [ "$?" -ne "0" ]; then
|
||||
echo "检测到下载的规则文件有更新,开始替换..." >$START_LOG
|
||||
mv /tmp/rules.yaml /etc/openclash/"$rule_source".yaml >/dev/null 2>&1
|
||||
sed -i '/^Rule:/a\##updated' /etc/openclash/"$rule_source".yaml >/dev/null 2>&1
|
||||
mv /tmp/rules.yaml /etc/openclash/"$RUlE_SOURCE".yaml >/dev/null 2>&1
|
||||
sed -i '/^Rule:/a\##updated' /etc/openclash/"$RUlE_SOURCE".yaml >/dev/null 2>&1
|
||||
echo "替换成功,重新加载 OpenClash 应用新规则..." >$START_LOG
|
||||
/etc/init.d/openclash reload 2>/dev/null
|
||||
echo "${LOGTIME} Other Rules Update Successful" >>$LOG_FILE
|
||||
echo "${LOGTIME} Other Rules 【$RUlE_SOURCE】 Update Successful" >>$LOG_FILE
|
||||
else
|
||||
echo "检测到下载的规则文件没有更新,停止继续操作..." >$START_LOG
|
||||
rm -rf /tmp/rules.yaml >/dev/null 2>&1
|
||||
echo "${LOGTIME} Updated Other Rules No Change, Do Nothing" >>$LOG_FILE
|
||||
echo "${LOGTIME} Updated Other Rules 【$RUlE_SOURCE】 No Change, Do Nothing" >>$LOG_FILE
|
||||
sleep 10
|
||||
echo "" >$START_LOG
|
||||
fi
|
||||
elif [ "$rule_source" = 0 ]; then
|
||||
elif [ "$RUlE_SOURCE" = 0 ]; then
|
||||
echo "未启用第三方规则,更新程序终止!" >$START_LOG
|
||||
rm -rf /tmp/rules.yaml >/dev/null 2>&1
|
||||
echo "${LOGTIME} Other Rules Not Enable, Update Stop" >>$LOG_FILE
|
||||
echo "${LOGTIME} Other Rules 【$RUlE_SOURCE】 Not Enable, Update Stop" >>$LOG_FILE
|
||||
sleep 10
|
||||
echo "" >$START_LOG
|
||||
else
|
||||
echo "第三方规则下载失败,请检查网络或稍后再试!" >$START_LOG
|
||||
rm -rf /tmp/rules.yaml >/dev/null 2>&1
|
||||
echo "${LOGTIME} Other Rules Update Error" >>$LOG_FILE
|
||||
echo "${LOGTIME} Other Rules 【$RUlE_SOURCE】 Update Error" >>$LOG_FILE
|
||||
sleep 10
|
||||
echo "" >$START_LOG
|
||||
fi
|
||||
|
||||
@ -8,13 +8,13 @@ LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
LOG_FILE="/tmp/openclash.log"
|
||||
LAST_OPVER="/tmp/openclash_last_version"
|
||||
LAST_VER=$(sed -n 1p "$LAST_OPVER" 2>/dev/null |sed "s/^v//g")
|
||||
http_port=$(uci get openclash.config.http_port 2>/dev/null)
|
||||
proxy_addr="127.0.0.1"
|
||||
HTTP_PORT=$(uci get openclash.config.http_port 2>/dev/null)
|
||||
PROXY_ADDR="127.0.0.1"
|
||||
|
||||
if [ "$(sed -n 1p /etc/openclash/openclash_version 2>/dev/null)" != "$(sed -n 1p $LAST_OPVER 2>/dev/null)" ] && [ -f "$LAST_OPVER" ]; then
|
||||
echo "开始下载 OpenClash-$LAST_VER ..." >$START_LOG
|
||||
if [ ! -z "$(pidof clash|sed 's/$//g')" ]; then
|
||||
curl -sL --connect-timeout 10 --retry 5 -x http://$proxy_addr:$http_port https://github.com/vernesong/OpenClash/releases/download/v"$LAST_VER"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk >/dev/null 2>&1
|
||||
if pidof clash >/dev/null; then
|
||||
curl -sL --connect-timeout 10 --retry 5 -x http://$PROXY_ADDR:$HTTP_PORT https://github.com/vernesong/OpenClash/releases/download/v"$LAST_VER"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk >/dev/null 2>&1
|
||||
else
|
||||
curl -sL --connect-timeout 10 --retry 5 https://github.com/vernesong/OpenClash/releases/download/v"$LAST_VER"/luci-app-openclash_"$LAST_VER"_all.ipk -o /tmp/openclash.ipk >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
@ -1,9 +1,15 @@
|
||||
#!/bin/sh
|
||||
CKTIME=$(date "+%Y-%m-%d-%H")
|
||||
LAST_OPVER="/tmp/openclash_last_version"
|
||||
version_url="https://raw.githubusercontent.com/vernesong/OpenClash/master/version"
|
||||
HTTP_PORT=$(uci get openclash.config.http_port 2>/dev/null)
|
||||
PROXY_ADDR="127.0.0.1"
|
||||
VERSION_URL="https://raw.githubusercontent.com/vernesong/OpenClash/master/version"
|
||||
if [ "$CKTIME" != "$(grep "CheckTime" $LAST_OPVER 2>/dev/null |awk -F ':' '{print $2}')" ]; then
|
||||
curl -sL --connect-timeout 10 --retry 2 "$version_url" -o $LAST_OPVER >/dev/null 2>&1
|
||||
if pidof clash >/dev/null; then
|
||||
curl -sL --connect-timeout 10 --retry 2 -x http://$PROXY_ADDR:$HTTP_PORT "$VERSION_URL" -o $LAST_OPVER >/dev/null 2>&1
|
||||
else
|
||||
curl -sL --connect-timeout 10 --retry 2 "$VERSION_URL" -o $LAST_OPVER >/dev/null 2>&1
|
||||
fi
|
||||
if [ "$?" -eq "0" ] && [ "$(ls -l $LAST_OPVER 2>/dev/null |awk '{print int($5)}')" -gt 0 ]; then
|
||||
if [ "$(sed -n 1p /etc/openclash/openclash_version 2>/dev/null)" = "$(sed -n 1p $LAST_OPVER 2>/dev/null)" ]; then
|
||||
sed -i "/^https:/i\CheckTime:${CKTIME}" "$LAST_OPVER" 2>/dev/null
|
||||
|
||||
@ -46,14 +46,9 @@ echo "开始更新【$CONFIG_NAME】的策略组配置..." >$START_LOG
|
||||
exit 0
|
||||
}
|
||||
|
||||
#判断各个区位置
|
||||
group_len=$(sed -n '/^ \{0,\}Proxy Group:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
provider_len=$(sed -n '/^ \{0,\}proxy-provider:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
if [ "$provider_len" -ge "$group_len" ]; then
|
||||
awk '/Proxy Group:/,/proxy-provider:/{print}' "$CONFIG_FILE" 2>/dev/null |sed 's/\"//g' 2>/dev/null |sed "s/\'//g" 2>/dev/null |sed 's/\t/ /g' 2>/dev/null >/tmp/yaml_group.yaml 2>&1
|
||||
else
|
||||
awk '/Proxy Group:/,/Rule:/{print}' "$CONFIG_FILE" 2>/dev/null |sed 's/\"//g' 2>/dev/null |sed "s/\'//g" 2>/dev/null |sed 's/\t/ /g' 2>/dev/null >/tmp/yaml_group.yaml 2>&1
|
||||
fi
|
||||
cp /tmp/Proxy_Group /tmp/yaml_group.yaml
|
||||
sed -i '/DIRECT/d' /tmp/yaml_group.yaml 2>/dev/null
|
||||
sed -i '/REJECT/d' /tmp/yaml_group.yaml 2>/dev/null
|
||||
|
||||
if [ "$servers_update" -ne "1" ] || [ "$servers_if_update" != "1" ] || [ -z "$(grep "config groups" "$CFG_FILE")" ]; then
|
||||
echo "正在删除旧配置..." >$START_LOG
|
||||
|
||||
@ -13,30 +13,43 @@ fi
|
||||
|
||||
if [ -f "$CFG_FILE" ]; then
|
||||
#检查关键字避免后续操作出错
|
||||
[ ! -z "$(grep "^ \{0,\}'Proxy':" "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{0,\}"Proxy":' "$CFG_FILE")" ] && {
|
||||
sed -i "/^ \{0,\}\'Proxy\':/c\Proxy:" "$CFG_FILE"
|
||||
sed -i '/^ \{0,\}\"Proxy\":/c\Proxy:' "$CFG_FILE"
|
||||
}
|
||||
#proxies
|
||||
sed -i "/^ \{0,\}\'Proxy\':/c\Proxy:" "$CFG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"Proxy\":/c\Proxy:' "$CFG_FILE" 2>/dev/null
|
||||
sed -i "/^ \{1,\}Proxy:/c\Proxy:" "$CFG_FILE" 2>/dev/null
|
||||
[ -z "$(grep "^Proxy:" "$CFG_FILE")" ] && {
|
||||
sed -i "s/^\'proxies\':/Proxy:/" "$CFG_FILE" 2>/dev/null
|
||||
sed -i 's/^\"proxies\":/Proxy:/' "$CFG_FILE" 2>/dev/null
|
||||
sed -i "s/^proxies:/Proxy:/" "$CFG_FILE" 2>/dev/null
|
||||
}
|
||||
|
||||
[ ! -z "$(grep "^ \{0,\}'proxy-provider':" "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{0,\}"proxy-provider":' "$CFG_FILE")" ] && {
|
||||
sed -i "/^ \{0,\}\'proxy-provider\:'/c\proxy-provider:" "$3"
|
||||
sed -i '/^ \{0,\}\"proxy-provider\":/c\proxy-provider:' "$3"
|
||||
}
|
||||
|
||||
[ ! -z "$(grep "^ \{0,\}'Proxy Group':" "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{0,\}"Proxy Group":' "$CFG_FILE")" ] && {
|
||||
sed -i "/^ \{0,\}\'Proxy Group\':/c\Proxy Group:" "$CFG_FILE"
|
||||
sed -i '/^ \{0,\}\"Proxy Group\":/c\Proxy Group:' "$CFG_FILE"
|
||||
}
|
||||
|
||||
[ ! -z "$(grep "^ \{0,\}'Rule':" "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{0,\}"Rule":' "$CFG_FILE")" ] && {
|
||||
sed -i "/^ \{0,\}\'Rule\':/c\Rule:" "$CFG_FILE"
|
||||
sed -i '/^ \{0,\}\"Rule\":/c\Rule:' "$CFG_FILE"
|
||||
}
|
||||
|
||||
[ ! -z "$(grep "^ \{0,\}'dns':" "$CFG_FILE")" ] || [ ! -z "$(grep '^ \{0,\}"dns":' "$CFG_FILE")" ] && {
|
||||
sed -i "/^ \{0,\}\'dns\':/c\dns:" "$CFG_FILE"
|
||||
sed -i '/^ \{0,\}\"dns\":/c\dns:' "$CFG_FILE"
|
||||
}
|
||||
#proxy-providers
|
||||
sed -i "/^ \{0,\}\'proxy-provider\':/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"proxy-provider\":/c\proxy-provider:' "$CFG_FILE" 2>/dev/null
|
||||
sed -i "/^ \{1,\}proxy-provider:/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
|
||||
sed -i "/^ \{0,\}\'proxy-providers\':/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"proxy-providers\":/c\proxy-provider:' "$CFG_FILE" 2>/dev/null
|
||||
sed -i "/^ \{0,\}proxy-providers:/c\proxy-provider:" "$CFG_FILE" 2>/dev/null
|
||||
|
||||
#proxy-groups
|
||||
sed -i "/^ \{0,\}\'Proxy Group\':/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"Proxy Group\":/c\Proxy Group:' "$CFG_FILE" 2>/dev/null
|
||||
sed -i "/^ \{1,\}Proxy Group:/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
|
||||
sed -i "/^ \{0,\}\'proxy-groups\':/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"proxy-groups\":/c\Proxy Group:' "$CFG_FILE" 2>/dev/null
|
||||
sed -i "/^ \{0,\}proxy-groups:/c\Proxy Group:" "$CFG_FILE" 2>/dev/null
|
||||
|
||||
#rules
|
||||
sed -i "/^ \{0,\}\'Rule\':/c\Rule:" "$CFG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"Rule\":/c\Rule:' "$CFG_FILE" 2>/dev/null
|
||||
sed -i "/^ \{1,\}Rule:/c\Rule:" "$CFG_FILE" 2>/dev/null
|
||||
sed -i "/^ \{0,\}\'rules\':/c\Rule:" "$CFG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"rules\":/c\Rule:' "$CFG_FILE" 2>/dev/null
|
||||
sed -i "/^ \{0,\}rules:/c\Rule:" "$CFG_FILE" 2>/dev/null
|
||||
|
||||
sed -i "/^ \{0,\}\'dns\':/c\dns:" "$CFG_FILE" 2>/dev/null
|
||||
sed -i '/^ \{0,\}\"dns\":/c\dns:' "$CFG_FILE" 2>/dev/null
|
||||
sed -i "/^ \{1,\}dns:/c\dns:" "$CFG_FILE" 2>/dev/null
|
||||
|
||||
#判断各个区位置
|
||||
group_len=$(sed -n '/^ \{0,\}Proxy Group:/=' "$CONFIG_FILE" 2>/dev/null)
|
||||
|
||||
@ -150,6 +150,6 @@ fi
|
||||
if [ ! -z "$(grep "^ \{0,\}- IP-CIDR,198.18.0.1/16" "$4")" ]; then
|
||||
sed -i "/^ \{0,\}- IP-CIDR,198.18.0.1\/16/c\- IP-CIDR,198.18.0.1\/16,REJECT,no-resolve" "$4"
|
||||
else
|
||||
sed -i "/^ \{0,\}- GEOIP/i\- IP-CIDR,198.18.0.1\/16,REJECT,no-resolve" "$4"
|
||||
sed -i '1,/^ \{0,\}- GEOIP/{/^ \{0,\}- GEOIP/s/^ \{0,\}- GEOIP/- IP-CIDR,198.18.0.1\/16,REJECT,no-resolve\n&/}' "$4"
|
||||
fi
|
||||
fi
|
||||
Loading…
Reference in New Issue
Block a user