2024-03-15 05:42:49 Auto Sync
This commit is contained in:
parent
a13d6a3eb8
commit
e1fbdb8666
@ -1,10 +1,13 @@
|
||||
# Copyright (C) 2019-2023 sirpdboy https://github.com/sirpdboy/luci-app-autotimeset
|
||||
#
|
||||
#
|
||||
# Copyright 2019-2023 sirpdboy
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
NAME:=autotimeset
|
||||
PKG_NAME:=luci-app-$(NAME)
|
||||
LUCI_TITLE:=LuCI support for Scheduled Time setting
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
|
@ -6,7 +6,9 @@ function index()
|
||||
return
|
||||
end
|
||||
entry({"admin", "control"}, firstchild(), "Control", 44).dependent = false
|
||||
entry({"admin", "control", "autotimeset"}, alias("admin", "control", "autotimeset", "base"), _("Scheduled Setting"), 20).dependent = true
|
||||
local e = entry({"admin", "control", "autotimeset"}, alias("admin", "control", "autotimeset", "base"), _("Scheduled Setting"), 20)
|
||||
e.dependent = false
|
||||
e.acl_depends = { "luci-app-autotimeset" }
|
||||
entry({"admin", "control", "autotimeset", "base"}, cbi("autotimeset/base"), _("Scheduled Setting"), 1).leaf = true
|
||||
entry({"admin", "control", "autotimeset", "log"}, form("autotimeset/log"), _("Log"), 2).leaf = true
|
||||
entry({"admin","control","autotimeset","dellog"},call("dellog"))
|
||||
|
@ -5,18 +5,19 @@ local e=luci.model.uci.cursor()
|
||||
local m,s,e
|
||||
|
||||
m=Map("autotimeset",translate("Scheduled task/startup task settings"),translate("<b>The original [Timing Settings] includes scheduled task execution and startup task execution. Presets include over 10 functions, including restart, shutdown, network restart, memory release, system cleaning, network sharing, network shutdown, automatic detection of network disconnects and reconnection, MWAN3 load balancing detection of reconnection, and custom scripts</b></br>") ..
|
||||
translate("N1-N5 is continuous, N1, N3, N5 is discontinuous, */N represents every N hours or every N minutes.The week can only be 0~6, the hour can only be 0~23, the minute can only be 0~59, the unavailable time is 48 hours.") ..
|
||||
translate(" <input class=\"cbi-button cbi-button-apply\" type=\"button\" value=\"" ..
|
||||
translate("Test/Verify Settings") ..
|
||||
" \" onclick=\"window.open('https://tool.lu/crontab/')\"/>"))
|
||||
translate("N1-N5 is continuous, N1, N3, N5 is discontinuous, */N represents every N hours or every N minutes.The week can only be 0~6, the hour can only be 0~23, the minute can only be 0~59, the unavailable time is 48 hours."))
|
||||
|
||||
s = m:section(TypedSection, 'global')
|
||||
s.anonymous=true
|
||||
|
||||
e=s:option(TextValue, "customscript" ,translate("Edit Custom Script"))
|
||||
e.description = translate("Only by editing the content of the custom script well and scheduling the custom script task can it be executed effectively.")
|
||||
e.description = translate("The execution content of the [Scheduled Customscript] in the task name")
|
||||
e.rows = 5
|
||||
e.rmempty = false
|
||||
|
||||
e=s:option(TextValue, "customscript2" ,translate("Edit Custom Script2"))
|
||||
e.description = translate("The execution content of the [Scheduled Customscript2] in the task name")
|
||||
e.rows = 5
|
||||
e.default = '#!/bin/sh'
|
||||
e.rmempty = false
|
||||
|
||||
s=m:section(TypedSection,"stime","")
|
||||
@ -37,8 +38,15 @@ e:value(9,translate("Scheduled DisReconn"))
|
||||
e:value(10,translate("Scheduled DisRereboot"))
|
||||
e:value(11,translate("Scheduled Restartmwan3"))
|
||||
e:value(12,translate("Scheduled Customscript"))
|
||||
e:value(13,translate("Scheduled Customscript2"))
|
||||
e:value(14,translate("Scheduled Wifiup"))
|
||||
e:value(15,translate("Scheduled Wifidown"))
|
||||
e.default=2
|
||||
|
||||
e=s:option(Flag,"enable",translate("Enable"))
|
||||
e.rmempty = false
|
||||
e.default=0
|
||||
|
||||
e=s:option(ListValue,"ttype",translate("Task Type"))
|
||||
e:value(0,translate("Scheduled task execution"))
|
||||
e:value(1,translate("Startup task"))
|
||||
@ -71,10 +79,6 @@ e=s:option(Value,"minute",translate("Minute(0~59)"))
|
||||
e.rmempty = false
|
||||
e.default = 0
|
||||
|
||||
e=s:option(Flag,"enable",translate("Enable"))
|
||||
e.rmempty = false
|
||||
e.default=0
|
||||
|
||||
m.apply_on_parse = true
|
||||
m.on_after_apply = function(self,map)
|
||||
luci.sys.exec("/etc/init.d/autotimeset start")
|
||||
|
@ -65,14 +65,29 @@ msgstr "检测断网重启"
|
||||
msgid "Scheduled Restartmwan3"
|
||||
msgstr "检测MWAN3失联重启服务"
|
||||
|
||||
msgid "Scheduled Wifidown"
|
||||
msgstr "关闭无线网络"
|
||||
|
||||
msgid "Scheduled Wifiup"
|
||||
msgstr "启用无线网络"
|
||||
|
||||
msgid "Edit Custom Script"
|
||||
msgstr "编辑自定义脚本"
|
||||
msgstr "【自定义脚本】编辑"
|
||||
|
||||
msgid "Edit Custom Script2"
|
||||
msgstr "【自定义脚本2】编辑"
|
||||
|
||||
msgid "Scheduled Customscript"
|
||||
msgstr "自定义脚本"
|
||||
|
||||
msgid "Only by editing the content of the custom script well and scheduling the custom script task can it be executed effectively."
|
||||
msgstr "编辑好自定义脚本内容,自定义脚本任务才能有效执行。"
|
||||
msgid "Scheduled Customscript2"
|
||||
msgstr "自定义脚本2"
|
||||
|
||||
msgid "The execution content of the [Scheduled Customscript] in the task name"
|
||||
msgstr "任务名称中【自定义脚本】执行内容"
|
||||
|
||||
msgid "The execution content of the [Scheduled Customscript2] in the task name"
|
||||
msgstr "任务名称中【自定义脚本2】执行内容"
|
||||
|
||||
msgid "Month(0~11)"
|
||||
msgstr "月份(0~11)【定时用】"
|
||||
|
@ -1 +0,0 @@
|
||||
zh-cn
|
106
luci-app-autotimeset/po/zh_Hans/autotimeset.po
Normal file
106
luci-app-autotimeset/po/zh_Hans/autotimeset.po
Normal file
@ -0,0 +1,106 @@
|
||||
|
||||
msgid "<b>The original [Timing Settings] includes scheduled task execution and startup task execution. Presets include over 10 functions, including restart, shutdown, network restart, memory release, system cleaning, network sharing, network shutdown, automatic detection of network disconnects and reconnection, MWAN3 load balancing detection of reconnection, and custom scripts</b></br>"
|
||||
msgstr "<b>任务设置包括定时任务执行和开机启动任务执行,预置:重启、关机、重启网络、释放内存、系统清理、网络共享、关闭网络、自动检测断网重连、自动检测断网重启、MWAN3负载均衡检测重连、自定义脚本等10多个功能.</b></br>"
|
||||
|
||||
msgid "N1-N5 is continuous, N1, N3, N5 is discontinuous, */N represents every N hours or every N minutes.The week can only be 0~6, the hour can only be 0~23, the minute can only be 0~59, the unavailable time is 48 hours."
|
||||
msgstr "N1-N5连续,N1,N3,N5不连续,*/N表示每N小时或每N分钟。月份范围0-11,星期范围0~6,小时范围0~23,分钟范围0~59,不可用72小时或者90分钟等连续范围。"
|
||||
|
||||
msgid "Scheduled task/startup task settings"
|
||||
msgstr "定时执行任务/开机启动任务设置"
|
||||
|
||||
msgid "Scheduled Setting"
|
||||
msgstr "任务设置"
|
||||
|
||||
msgid "Test/Verify Settings"
|
||||
msgstr "测试/验证设置"
|
||||
|
||||
msgid "Scheduled Type"
|
||||
msgstr "任务名称"
|
||||
|
||||
msgid "Task Type"
|
||||
msgstr "任务类型"
|
||||
|
||||
msgid "Scheduled task execution"
|
||||
msgstr "定时执行任务"
|
||||
|
||||
msgid "Startup task"
|
||||
msgstr "开机启动任务"
|
||||
|
||||
msgid "Startup delay time"
|
||||
msgstr "延迟时间【开机用】"
|
||||
|
||||
msgid "Log"
|
||||
msgstr "日志"
|
||||
|
||||
msgid "Scheduled Reboot"
|
||||
msgstr "重启机器"
|
||||
|
||||
msgid "Scheduled Poweroff"
|
||||
msgstr "关闭机器"
|
||||
|
||||
msgid "Scheduled ReNetwork"
|
||||
msgstr "重启网络"
|
||||
|
||||
msgid "Scheduled RestartSamba"
|
||||
msgstr "重启网络共享"
|
||||
|
||||
msgid "Scheduled Restartwan"
|
||||
msgstr "重启WAN"
|
||||
|
||||
msgid "Scheduled Closewan"
|
||||
msgstr "关闭网络"
|
||||
|
||||
msgid "Scheduled Clearmem"
|
||||
msgstr "释放内存"
|
||||
|
||||
msgid "Scheduled Sysfree"
|
||||
msgstr "系统清理(会重启机器)"
|
||||
|
||||
msgid "Scheduled DisReconn"
|
||||
msgstr "检测断网重连"
|
||||
|
||||
msgid "Scheduled DisRereboot"
|
||||
msgstr "检测断网重启"
|
||||
|
||||
msgid "Scheduled Restartmwan3"
|
||||
msgstr "检测MWAN3失联重启服务"
|
||||
|
||||
msgid "Scheduled Wifidown"
|
||||
msgstr "关闭无线网络"
|
||||
|
||||
msgid "Scheduled Wifiup"
|
||||
msgstr "启用无线网络"
|
||||
|
||||
msgid "Edit Custom Script"
|
||||
msgstr "【自定义脚本】编辑"
|
||||
|
||||
msgid "Edit Custom Script2"
|
||||
msgstr "【自定义脚本2】编辑"
|
||||
|
||||
msgid "Scheduled Customscript"
|
||||
msgstr "自定义脚本"
|
||||
|
||||
msgid "Scheduled Customscript2"
|
||||
msgstr "自定义脚本2"
|
||||
|
||||
msgid "The execution content of the [Scheduled Customscript] in the task name"
|
||||
msgstr "任务名称中【自定义脚本】执行内容"
|
||||
|
||||
msgid "The execution content of the [Scheduled Customscript2] in the task name"
|
||||
msgstr "任务名称中【自定义脚本2】执行内容"
|
||||
|
||||
msgid "Month(0~11)"
|
||||
msgstr "月份(0~11)【定时用】"
|
||||
|
||||
msgid "Week Day(0~6)"
|
||||
msgstr "星期(0~6)【定时用】"
|
||||
|
||||
msgid "Everyday"
|
||||
msgstr "每天【定时用】"
|
||||
|
||||
msgid "Hour(0~23)"
|
||||
msgstr "小时(0~23)【定时用】"
|
||||
|
||||
msgid "Minute(0~59)"
|
||||
msgstr "分钟(0~59)【定时用】"
|
||||
|
@ -1 +1 @@
|
||||
#!/bin/sh
|
||||
# Sh script rules
|
||||
|
@ -0,0 +1 @@
|
||||
# Sh script rules
|
@ -1,4 +1,3 @@
|
||||
|
||||
config global
|
||||
option enabled '0'
|
||||
option customscript '#!/bin/sh'
|
||||
@ -16,12 +15,12 @@ config stime
|
||||
config stime
|
||||
option minute '0'
|
||||
option month '*'
|
||||
option hour '*/5'
|
||||
option enable '0'
|
||||
option week '1,3,5'
|
||||
option ttype '1'
|
||||
option delay '10'
|
||||
option stype '1'
|
||||
option ttype '0'
|
||||
option hour '1'
|
||||
|
||||
config stime
|
||||
option week '*'
|
||||
@ -30,8 +29,8 @@ config stime
|
||||
option ttype '0'
|
||||
option delay '10'
|
||||
option stype '10'
|
||||
option hour '0'
|
||||
option minute '*/5'
|
||||
option hour '*'
|
||||
|
||||
config stime
|
||||
option week '*'
|
||||
@ -55,21 +54,21 @@ config stime
|
||||
|
||||
config stime
|
||||
option week '*'
|
||||
option hour '0'
|
||||
option minute '*/5'
|
||||
option month '*'
|
||||
option stype '11'
|
||||
option ttype '1'
|
||||
option delay '20'
|
||||
option enable '0'
|
||||
option hour '*'
|
||||
|
||||
config stime
|
||||
option month '*'
|
||||
option week '*'
|
||||
option hour '0'
|
||||
option enable '0'
|
||||
option minute '*/5'
|
||||
option stype '12'
|
||||
option ttype '1'
|
||||
option delay '30'
|
||||
option hour '*'
|
||||
|
||||
|
@ -8,17 +8,12 @@ LOG=$TMP/autotimeset.log
|
||||
TT=/etc/init.d/autotimesetrun
|
||||
CR=/etc/crontabs/root
|
||||
[ ! -d $TMP ] && mkdir -p $TMP 2>/dev/null
|
||||
[ -s $LOG ] && echo ' ' >> $LOG
|
||||
[ -s $LOG ] && echo -e '' >> $LOG
|
||||
run_autotimeset()
|
||||
{
|
||||
ssum=$(grep -c stime /etc/config/autotimeset)
|
||||
customscript=$(uci -q get autotimeset.@global[0].customscript ) || customscript='#!/bin/sh'
|
||||
script=`echo $customscript | grep '#!/bin/sh'` >/dev/null 2>&1
|
||||
[ $script ] && echo $script > /etc/autotimeset/timesetcustomscript || {
|
||||
echo '#!/bin/sh' >/etc/autotimeset/timesetcustomscript
|
||||
echo $customscript >>/etc/autotimeset/timesetcustomscript
|
||||
}
|
||||
echo 'start(){' >>$TT
|
||||
[ `uci -q get autotimeset.@global[0].customscript | wc -l ` > 0 ] && uci -q get autotimeset.@global[0].customscript > /etc/autotimeset/timesetcustomscript
|
||||
[ `uci -q get autotimeset.@global[0].customscript2 | wc -l ` > 0 ] && uci -q get autotimeset.@global[0].customscript2 > /etc/autotimeset/timesetcustomscript2
|
||||
for i in $(seq 0 $((ssum-1)))
|
||||
do
|
||||
enable=$(uci -q get autotimeset.@stime[$i].enable )
|
||||
@ -73,7 +68,6 @@ do
|
||||
local cmd="$minute $hour * $month $week /usr/bin/timesethandler disrereboot Scheduled_task"
|
||||
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler disrereboot Startup_task" >>$TT
|
||||
;;
|
||||
|
||||
11)
|
||||
local cmd="$minute $hour * $month $week /usr/bin/timesethandler restartmwan3 Scheduled_task"
|
||||
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler restartmwan3 Startup_task" >>$TT
|
||||
@ -82,12 +76,21 @@ do
|
||||
local cmd="$minute $hour * $month $week /usr/bin/timesethandler customscript Scheduled_task"
|
||||
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler customscript Startup_task" >>$TT
|
||||
;;
|
||||
13)
|
||||
local cmd="$minute $hour * $month $week /usr/bin/timesethandler customscript2 Scheduled_task"
|
||||
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler customscript2 Startup_task" >>$TT
|
||||
;;
|
||||
14)
|
||||
local cmd="$minute $hour * $month $week /usr/bin/timesethandler upwifi Scheduled_task"
|
||||
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler upwifi Startup_task" >>$TT
|
||||
;;
|
||||
15)
|
||||
local cmd="$minute $hour * $month $week /usr/bin/timesethandler downwifi Scheduled_task"
|
||||
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler downwifi Startup_task" >>$TT
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
echo '}' >>$TT
|
||||
}
|
||||
|
||||
start()
|
||||
@ -95,12 +98,14 @@ start()
|
||||
del_cru
|
||||
[ -n "`tail -c1 $CR`" ] && echo >> $CR
|
||||
run_autotimeset
|
||||
echo '}' >>$TT
|
||||
/etc/init.d/cron reload
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
del_cru
|
||||
echo '}' >>$TT
|
||||
/etc/init.d/cron reload
|
||||
}
|
||||
|
||||
@ -110,8 +115,8 @@ restart()
|
||||
}
|
||||
|
||||
del_cru()
|
||||
{
|
||||
echo -e '#!/bin/sh /etc/rc.common\n\nSTART=99\n' > $TT
|
||||
{
|
||||
echo -e '#!/bin/sh /etc/rc.common\n\nSTART=99\nstart(){\necho "Service autotimesetrun started! " >> $LOG\n' > $TT
|
||||
sed -i '/timesethandler/d' $CR >/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
start(){
|
||||
auto=1
|
||||
echo "Service autotimesetrun started!" >/dev/null
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
chmod +x /etc/init.d/autotimeset /usr/bin/timesethandler
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@autotimeset[-1]
|
||||
add ucitrack autotimeset
|
||||
set ucitrack.@autotimeset[-1].init=autotimeset
|
||||
commit ucitrack
|
||||
EOF
|
||||
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*
|
||||
exit 0
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
# author 2021 jjm2473
|
||||
# author 2020-2023 sirpdboy
|
||||
# author 2020-2024 sirpdboy
|
||||
TMP_T=/var/autotimeset/autotimeset.tmp
|
||||
LOG=/etc/autotimeset/autotimeset.log
|
||||
log(){
|
||||
@ -114,10 +114,29 @@ trigger() {
|
||||
[ -s /usr/sbin/mwan3 ] && remwan3
|
||||
;;
|
||||
customscript)
|
||||
script=`cat /etc/autotimeset/timesetcustomscript ` >/dev/null 2>&1
|
||||
[ $script ] && source /etc/autotimeset/timesetcustomscript
|
||||
script=`cat /etc/autotimeset/timesetcustomscript | wc -l`
|
||||
[[ $script > 0 ]] && source /etc/autotimeset/timesetcustomscript
|
||||
log "CustomScript succeeded!"
|
||||
;;
|
||||
customscript2)
|
||||
script=`cat /etc/autotimeset/timesetcustomscript2 | wc -l`
|
||||
[[ $script > 0 ]] && source /etc/autotimeset/timesetcustomscript2
|
||||
log "CustomScript succeeded!"
|
||||
;;
|
||||
upwifi)
|
||||
ifconfig wlan0 up
|
||||
uci set wireless.radio0.disabled=0
|
||||
uci set wireless.radio1.disabled=0
|
||||
uci commit wireless
|
||||
wifi up
|
||||
;;
|
||||
downwifi)
|
||||
ifconfig wlan0 down
|
||||
uci set wireless.radio0.disabled=1
|
||||
uci set wireless.radio1.disabled=1
|
||||
uci commit wireless
|
||||
wifi down
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -1,119 +0,0 @@
|
||||
#! /bin/bash
|
||||
|
||||
#允许尝试错误的次数
|
||||
tryErrNum=10
|
||||
#允许尝试错误在多长时间范围,单位秒,与tryErrNum一起生效
|
||||
tryTimeOut=300
|
||||
#需要被封禁的多个ip字符串,逗号隔开,这里为空
|
||||
dropIpList=""
|
||||
#logread里面标识字符串,Bad password attempt for 是ssh root登录密码错误log,luci: failed login on 是登录web错误log
|
||||
errStr=("Bad password attempt for" "luci: failed login on")
|
||||
#查询logread 日志的时间间隔,单位秒
|
||||
timesleep=30
|
||||
|
||||
#从根据字符串从日志里面提取要封禁的ip,追加到 dropIpList 变量
|
||||
getdropip() {
|
||||
#对过滤的日志倒叙
|
||||
lines=$(logread | grep $1 | sed -n '1!G;h;$p')
|
||||
linesNum=$(echo -n "$lines" | wc -l)
|
||||
#定义字典变量
|
||||
declare -A dict
|
||||
#
|
||||
if [ "$linesNum" -gt "$tryErrNum" ];then
|
||||
while read line;
|
||||
do
|
||||
ip=$(echo -n "$line" | awk '{print $NF}' | awk -F":" '{print $1}')
|
||||
time=$(echo -n "$line" | awk '{print $4}' | awk -F":" '{sum += $1*3600 + $2*60 + $3};END {print sum}')
|
||||
ok=${dict[$ip]}
|
||||
if [ -z $ok ];then
|
||||
dict[$ip]=1
|
||||
time=$(date | awk '{print $4}' | awk -F":" '{sum += $1*3600 + $2*60+ $3};END {print sum}')
|
||||
dict[${ip}_endtime]=$time
|
||||
else
|
||||
if [ ${dict[$ip]} -lt "$tryErrNum" ];then
|
||||
dict[$ip]=$(expr ${dict[$ip]} + 1)
|
||||
dict[${ip}_starttime]=$time
|
||||
fi
|
||||
fi
|
||||
done < <(echo -n "$lines")
|
||||
|
||||
for key in ${!dict[@]};
|
||||
do
|
||||
if ! [[ "$key" =~ "starttime" ]] && ! [[ "$key" =~ "endtime" ]];then
|
||||
if [ ${dict[$key]} -eq "$tryErrNum" ];then
|
||||
timeDiff=$(expr ${dict[${key}_endtime]} - ${dict[${key}_starttime]})
|
||||
if [ "$timeDiff" -gt 0 ] && [ "$timeDiff" -lt "$tryTimeOut" ];then
|
||||
#追加需要封禁的ip到变量
|
||||
dropIpList=$dropIpList,$key
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
#errStr 字符串遍历,分别从log里面匹配,提取要封禁ip
|
||||
startGetDropIp(){
|
||||
i=0
|
||||
while :
|
||||
do
|
||||
errstr=${errStr[$i]}
|
||||
if [ -z "$errstr" ];then
|
||||
break
|
||||
fi
|
||||
i=$(expr $i + 1)
|
||||
|
||||
getdropip $errstr
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
#初始化ipset iptable
|
||||
intEnv(){
|
||||
ipset list BlockIpList
|
||||
if ! [ "$?" == 0 ];
|
||||
then
|
||||
ipset create BlockIpList hash:net timeout 300
|
||||
iptables -I INPUT -m set --match-set BlockIpList src -p tcp -m tcp --dport 22 -j DROP
|
||||
iptables -I INPUT -m set --match-set BlockIpList src -p tcp -m tcp --dport 80 -j DROP
|
||||
iptables -I INPUT -s 192.168.0.0/16 -j ACCEPT
|
||||
fi
|
||||
}
|
||||
#把要封禁的ip添加到ipset BlockIpList集合
|
||||
ipsetAddIp(){
|
||||
dropIpListNew=""
|
||||
for ip in $(echo -n "$dropIpList" | sed 's/,/ /g')
|
||||
do
|
||||
ipset add BlockIpList $ip
|
||||
if [ "$?" -eq 0 ];then
|
||||
dropIpListNew=$dropIpListNew,$ip
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
sendlogger(){
|
||||
if [ -n "$dropIpListNew" ];then
|
||||
echo -e "autotimeset:MyOpenwrt IP封禁提醒:$dropIpListNew"
|
||||
logger -p warn -t "autotimeset" ",定时设置提醒: IP封禁:$dropIpListNew ---- 时间:`date `"
|
||||
fi
|
||||
}
|
||||
|
||||
#检查当前进程是否存在
|
||||
PocessNum=$(ps | grep timesetsecurity | grep -v grep | wc -l)
|
||||
if [ "$PocessNum" -gt 2 ];then
|
||||
#已经存在进程,直接退出当前进程
|
||||
kill -9 $$
|
||||
else
|
||||
intEnv
|
||||
|
||||
while :
|
||||
do
|
||||
sleep $timesleep
|
||||
dropIpList=""
|
||||
startGetDropIp
|
||||
ipsetAddIp
|
||||
sendlogger
|
||||
done
|
||||
fi
|
@ -1,8 +1,8 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-openclash
|
||||
PKG_VERSION:=0.46.001
|
||||
PKG_RELEASE:=247
|
||||
PKG_VERSION:=0.46.003
|
||||
PKG_RELEASE:=248
|
||||
PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash>
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
@ -654,7 +654,7 @@ function set_subinfo_url()
|
||||
end
|
||||
|
||||
function sub_info_get()
|
||||
local filepath, filename, sub_url, sub_info, info, upload, download, total, expire, http_code, len, percent, day_left, day_expire
|
||||
local filepath, filename, sub_url, sub_info, info, upload, download, total, expire, http_code, len, percent, day_left, day_expire, surplus, used
|
||||
local info_tb = {}
|
||||
filename = luci.http.formvalue("filename")
|
||||
sub_info = ""
|
||||
@ -705,7 +705,6 @@ function sub_info_get()
|
||||
else
|
||||
day_left = 0
|
||||
end
|
||||
|
||||
if used and total and used < total then
|
||||
percent = string.format("%.1f",((total-used)/total)*100) or nil
|
||||
elseif used == nil or total == nil or total == 0 then
|
||||
@ -713,6 +712,7 @@ function sub_info_get()
|
||||
else
|
||||
percent = 0
|
||||
end
|
||||
surplus = fs.filesize(total - used) or "null"
|
||||
total = fs.filesize(total) or "null"
|
||||
used = fs.filesize(used) or "null"
|
||||
sub_info = "Successful"
|
||||
@ -727,6 +727,7 @@ function sub_info_get()
|
||||
luci.http.write_json({
|
||||
http_code = http_code,
|
||||
sub_info = sub_info,
|
||||
surplus = surplus,
|
||||
used = used,
|
||||
total = total,
|
||||
percent = percent,
|
||||
@ -1071,7 +1072,8 @@ function action_status()
|
||||
db_forward_ssl = db_foward_ssl(),
|
||||
web = is_web(),
|
||||
cn_port = cn_port(),
|
||||
restricted_mode = restricted_mode();
|
||||
restricted_mode = restricted_mode(),
|
||||
core_type = uci:get("openclash", "config", "core_type") or "Dev";
|
||||
})
|
||||
end
|
||||
|
||||
|
@ -236,6 +236,10 @@ o = s:taboption("traffic_control", Flag, "disable_udp_quic", font_red..bold_on..
|
||||
o.description = translate("Prevent YouTube and Others To Use QUIC Transmission")..", "..font_red..bold_on..translate("REJECT UDP Traffic(Not Include CN) On Port 443")..bold_off..font_off
|
||||
o.default = 1
|
||||
|
||||
o = s:taboption("traffic_control", Flag, "skip_proxy_address", translate("Skip Proxy Address"))
|
||||
o.description = translate("Bypassing Server Addresses And Preventing Duplicate Proxies")
|
||||
o.default = 0
|
||||
|
||||
o = s:taboption("traffic_control", Value, "common_ports", font_red..bold_on..translate("Common Ports Proxy Mode")..bold_off..font_off)
|
||||
o.description = translate("Only Common Ports, Prevent BT/P2P Passing")
|
||||
o:value("0", translate("Disable"))
|
||||
|
@ -252,11 +252,11 @@
|
||||
if ( x && x.status == 200 ) {
|
||||
if ( status.restricted_mode != "1" )
|
||||
{
|
||||
clash.innerHTML = status.clash ? '<b style=color:green><%:Running%></b>' : '<b style=color:red><%:Not Running%></b>';
|
||||
clash.innerHTML = status.clash ? '<b style=color:green>' + status.core_type +' <%:Running%></b>' : '<b style=color:red><%:Not Running%></b>';
|
||||
}
|
||||
else
|
||||
{
|
||||
clash.innerHTML = status.clash ? '<b style=color:green><%:Running%> <%:<Limited State>%></b>' : '<b style=color:red><%:Not Running%></b>';
|
||||
clash.innerHTML = status.clash ? '<b style=color:green>' + status.core_type +' <%:Running%> <%:<Limited State>%></b>' : '<b style=color:red><%:Not Running%></b>';
|
||||
}
|
||||
watchdog.innerHTML = status.watchdog ? ' | <%:Daemons%>: <b style=color:green><%:Running%></b>' : ' | <%:Daemons%>: <b style=color:red><%:Not Running%></b>';
|
||||
dase.innerHTML = status.dase ? "<b style=color:green>"+status.dase+"</b>" : "<b style=color:red>"+"<%:Not Set%>"+"</b>";
|
||||
|
@ -72,8 +72,7 @@ function sub_info_refresh_<%=idname%>()
|
||||
retry_<%=idname%> = 0;
|
||||
localStorage.setItem("<%=filename%>",JSON.stringify(status));
|
||||
document.getElementById('<%=idname%>').className = "sub_tab_show";
|
||||
document.getElementById('<%=idname%>').innerHTML = progressbar_<%=idname%>((status.used), (status.total), (status.percent), false, false, (status.expire), (status.day_left));
|
||||
//document.getElementById('<%=idname%>').innerHTML = "<%:Plan Traffic%>" + ": " + "<span style=color:green>" + status.used + "</span> | <span style=color:green>" + status.total + "</span> <br/> <%:Plan Expiration Time%>: " + "<span style=color:green>" + status.expire + "</span>";
|
||||
document.getElementById('<%=idname%>').innerHTML = progressbar_<%=idname%>((status.surplus ? status.surplus : status.used), (status.total), (status.percent), false, false, (status.expire), (status.day_left));
|
||||
}
|
||||
else if ( x && x.status == 200 && status.sub_info == "No Sub Info Found" ) {
|
||||
retry_<%=idname%> = 0;
|
||||
@ -110,8 +109,7 @@ function sub_info_get_<%=idname%>()
|
||||
document.getElementById('<%=idname%>').innerHTML = "<span><%:No Sub Info Found%></span>";
|
||||
}
|
||||
else {
|
||||
//document.getElementById('<%=idname%>').innerHTML = "<%:Plan Traffic%>" + ": " + "<span style=color:green>" + save_info.used + "</span> | <span style=color:green>" + save_info.total + "</span> <br/> <%:Plan Expiration Time%>: " + "<span style=color:green>" + save_info.expire + "</span>";
|
||||
document.getElementById('<%=idname%>').innerHTML = progressbar_<%=idname%>((save_info.used), (save_info.total), (save_info.percent ? save_info.percent : 0), false, false, (save_info.expire), (save_info.day_left ? save_info.day_left : 0));
|
||||
document.getElementById('<%=idname%>').innerHTML = progressbar_<%=idname%>((save_info.surplus ? save_info.surplus : save_info.used), (save_info.total), (save_info.percent ? save_info.percent : 0), false, false, (save_info.expire), (save_info.day_left ? save_info.day_left : 0));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -3240,6 +3240,9 @@ msgstr "大陆域名 DNS 服务器"
|
||||
msgid "Specify DNS Server For CN Domain Lists, Only One IP Server Address Support"
|
||||
msgstr "指定大陆域名的 DNS 服务器,只支持填写一个IP地址"
|
||||
|
||||
msgid "Warning: Dnsmasq Work is Unnormal, Setting The Firewall DNS Hijacking Rules..."
|
||||
msgstr "警告:检测到 Dnsmasq 工作异常,设置防火墙 DNS 劫持规则..."
|
||||
|
||||
msgid "Tip: Dnsmasq Work is Normal, Restore The Firewall DNS Hijacking Rules..."
|
||||
msgstr "提示:检测到 Dnsmasq 正常工作,还原防火墙 DNS 劫持规则..."
|
||||
|
||||
@ -3487,4 +3490,10 @@ msgid "Error: Set Fallback DNS Proxy Group Failed,"
|
||||
msgstr "错误:Fallback DNS 代理策略组设置失败,"
|
||||
|
||||
msgid "To Use in Fake-IP Mode, Please Switch The Dns Redirect Mode To Firewall Forwarding"
|
||||
msgstr "要在 Fake-IP 模式下使用,请将 Dns 重定向模式切换为防火墙转发模式"
|
||||
msgstr "要在 Fake-IP 模式下使用,请将 Dns 重定向模式切换为防火墙转发模式"
|
||||
|
||||
msgid "Skip Proxy Address"
|
||||
msgstr "绕过服务器地址"
|
||||
|
||||
msgid "Bypassing Server Addresses And Preventing Duplicate Proxies"
|
||||
msgstr "绕过服务器地址,防止重复代理"
|
@ -213,6 +213,7 @@ uci -q set network.utun=interface
|
||||
uci -q set network.utun.proto=none
|
||||
uci -q set network.utun.device=utun
|
||||
uci -q set network.utun.device=utun
|
||||
uci -q set network.utun.auto='0'
|
||||
uci -q commit network
|
||||
|
||||
config_load "firewall"
|
||||
|
@ -25,21 +25,26 @@ china_ip_route=$(uci -q get openclash.config.china_ip_route)
|
||||
en_mode=$(uci -q get openclash.config.en_mode)
|
||||
fakeip_range=$(uci -q get openclash.config.fakeip_range || echo "198.18.0.1/16")
|
||||
ipv6_mode=$(uci -q get openclash.config.ipv6_mode || echo 0)
|
||||
skip_proxy_address=$(uci -q get openclash.config.skip_proxy_address || echo 0)
|
||||
CRASH_NUM=0
|
||||
CFG_UPDATE_INT=1
|
||||
SKIP_PROXY_ADDRESS=1
|
||||
SKIP_PROXY_ADDRESS_INTERVAL=30
|
||||
STREAM_DOMAINS_PREFETCH=1
|
||||
STREAM_AUTO_SELECT=1
|
||||
FW4=$(command -v fw4)
|
||||
|
||||
|
||||
check_dnsmasq() {
|
||||
if [ -z "$(echo "$en_mode" |grep "redir-host")" ] && [ "$china_ip_route" -eq 1 ] && [ "$enable_redirect_dns" != "2" ]; then
|
||||
DNSPORT=$(uci -q get dhcp.@dnsmasq[0].port)
|
||||
if [ -z "$DNSPORT" ]; then
|
||||
DNSPORT=$(netstat -nlp |grep -E '127.0.0.1:.*dnsmasq' |awk -F '127.0.0.1:' '{print $2}' |awk '{print $1}' |head -1 || echo 53)
|
||||
fi
|
||||
if [ "$(nslookup www.baidu.com 127.0.0.1:"$DNSPORT" >/dev/null 2>&1 || echo $?)" = "1" ]; then
|
||||
if [ "$(nslookup www.baidu.com >/dev/null 2>&1 || echo $?)" = "1" ]; then
|
||||
if [ -n "$FW4" ]; then
|
||||
if [ -z "$(nft list chain inet fw4 nat_output |grep '12353')" ]; then
|
||||
LOG_OUT "Warning: Dnsmasq Work is Unnormal, Setting The Firewall DNS Hijacking Rules..."
|
||||
nft insert rule inet fw4 dstnat position 0 tcp dport 53 counter redirect to "$dns_port" comment \"OpenClash DNS Hijack\" 2>/dev/null
|
||||
nft insert rule inet fw4 dstnat position 0 udp dport 53 counter redirect to "$dns_port" comment \"OpenClash DNS Hijack\" 2>/dev/null
|
||||
nft 'add chain inet fw4 nat_output { type nat hook output priority -1; }' 2>/dev/null
|
||||
@ -59,6 +64,7 @@ check_dnsmasq() {
|
||||
fi
|
||||
else
|
||||
if [ -z "$(iptables -t nat -nL OUTPUT --line-number |grep '12353')" ]; then
|
||||
LOG_OUT "Warning: Dnsmasq Work is Unnormal, Setting The Firewall DNS Hijacking Rules..."
|
||||
iptables -t nat -I PREROUTING -p udp --dport 53 -j REDIRECT --to-ports "$dns_port" -m comment --comment "OpenClash DNS Hijack" 2>/dev/null
|
||||
iptables -t nat -I PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports "$dns_port" -m comment --comment "OpenClash DNS Hijack" 2>/dev/null
|
||||
iptables -t nat -I OUTPUT -p udp --dport 53 -m owner ! --uid-owner 65534 -j REDIRECT --to-ports "$dns_port" -m comment --comment "OpenClash DNS Hijack" 2>/dev/null
|
||||
@ -125,6 +131,7 @@ check_dnsmasq() {
|
||||
}
|
||||
|
||||
check_dnsmasq
|
||||
SLOG_CLEAN
|
||||
sleep 60
|
||||
|
||||
while :;
|
||||
@ -310,99 +317,106 @@ fi
|
||||
fi
|
||||
|
||||
## Skip Proxies Address
|
||||
ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "
|
||||
begin
|
||||
Value = YAML.load_file('$CONFIG_FILE');
|
||||
rescue Exception => e
|
||||
puts '${LOGTIME} Error: Load File Failed,【' + e.message + '】';
|
||||
end;
|
||||
begin
|
||||
Thread.new{
|
||||
reg = /^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$/;
|
||||
reg6 = /^(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))|\[(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))\](?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$/i;
|
||||
if Value.key?('proxies') or Value.key?('proxy-providers') then
|
||||
firewall_v = '$FW4';
|
||||
if firewall_v.empty? then
|
||||
firewall_v = 'ipt'
|
||||
else
|
||||
firewall_v = 'nft'
|
||||
if [ "$skip_proxy_address" -eq 1 ]; then
|
||||
if [ "$SKIP_PROXY_ADDRESS" -eq 1 ] || [ "$(expr "$SKIP_PROXY_ADDRESS" % "$SKIP_PROXY_ADDRESS_INTERVAL")" -eq 0 ]; then
|
||||
ruby -ryaml -rYAML -I "/usr/share/openclash" -E UTF-8 -e "
|
||||
begin
|
||||
Value = YAML.load_file('$CONFIG_FILE');
|
||||
rescue Exception => e
|
||||
puts '${LOGTIME} Error: Load File Failed,【' + e.message + '】';
|
||||
end;
|
||||
ips = Array.new;
|
||||
servers = Array.new;
|
||||
if Value.key?('proxies') and not Value['proxies'].nil? then
|
||||
Value['proxies'].each do
|
||||
|i|
|
||||
if i['server'] then
|
||||
if not i['server'] =~ reg and not i['server'] =~ reg6 and not servers.include?(i['server']) then
|
||||
servers = servers.push(i['server']).uniq
|
||||
syscall = '/usr/share/openclash/openclash_debug_dns.lua 2>/dev/null \"' + i['server'] + '\" \"true\"'
|
||||
if IO.popen(syscall).read.split(/\n+/) then
|
||||
ips = ips | IO.popen(syscall).read.split(/\n+/)
|
||||
begin
|
||||
Thread.new{
|
||||
reg = /^((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$/;
|
||||
reg6 = /^(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))|\[(?:(?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))\](?::(?:[0-9]|[1-9][0-9]{1,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]))?$/i;
|
||||
if Value.key?('proxies') or Value.key?('proxy-providers') then
|
||||
firewall_v = '$FW4';
|
||||
if firewall_v.empty? then
|
||||
firewall_v = 'ipt'
|
||||
else
|
||||
firewall_v = 'nft'
|
||||
end;
|
||||
ips = Array.new;
|
||||
servers = Array.new;
|
||||
if Value.key?('proxies') and not Value['proxies'].nil? then
|
||||
Value['proxies'].each do
|
||||
|i|
|
||||
if i['server'] then
|
||||
if not i['server'] =~ reg and not i['server'] =~ reg6 and not servers.include?(i['server']) then
|
||||
servers = servers.push(i['server']).uniq
|
||||
syscall = '/usr/share/openclash/openclash_debug_dns.lua 2>/dev/null \"' + i['server'] + '\" \"true\"'
|
||||
if IO.popen(syscall).read.split(/\n+/) then
|
||||
ips = ips | IO.popen(syscall).read.split(/\n+/)
|
||||
end;
|
||||
else
|
||||
ips = ips.push(i['server']).uniq
|
||||
end;
|
||||
end;
|
||||
else
|
||||
ips = ips.push(i['server']).uniq
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if Value.key?('proxy-providers') and not Value['proxy-providers'].nil? then
|
||||
Value['proxy-providers'].values.each do
|
||||
|i,path|
|
||||
if i['path'] and not i['path'].empty? then
|
||||
if i['path'].split('/')[0] == '.' then
|
||||
path = '/etc/openclash/'+i['path'].split('./')[1]
|
||||
else
|
||||
path = i['path']
|
||||
end;
|
||||
if File::exist?(path) then
|
||||
if YAML.load_file(path).key?('proxies') and not YAML.load_file(path)['proxies'].nil? then
|
||||
YAML.load_file(path)['proxies'].each do
|
||||
|j|
|
||||
if j['server'] then
|
||||
if not j['server'] =~ reg and not j['server'] =~ reg6 and not servers.include?(j['server']) then
|
||||
servers = servers.push(j['server']).uniq
|
||||
syscall = '/usr/share/openclash/openclash_debug_dns.lua 2>/dev/null \"' + j['server'] + '\" \"true\"'
|
||||
if IO.popen(syscall).read.split(/\n+/) then
|
||||
ips = ips | IO.popen(syscall).read.split(/\n+/)
|
||||
if Value.key?('proxy-providers') and not Value['proxy-providers'].nil? then
|
||||
Value['proxy-providers'].values.each do
|
||||
|i,path|
|
||||
if i['path'] and not i['path'].empty? then
|
||||
if i['path'].split('/')[0] == '.' then
|
||||
path = '/etc/openclash/'+i['path'].split('./')[1]
|
||||
else
|
||||
path = i['path']
|
||||
end;
|
||||
if File::exist?(path) then
|
||||
if YAML.load_file(path).key?('proxies') and not YAML.load_file(path)['proxies'].nil? then
|
||||
YAML.load_file(path)['proxies'].each do
|
||||
|j|
|
||||
if j['server'] then
|
||||
if not j['server'] =~ reg and not j['server'] =~ reg6 and not servers.include?(j['server']) then
|
||||
servers = servers.push(j['server']).uniq
|
||||
syscall = '/usr/share/openclash/openclash_debug_dns.lua 2>/dev/null \"' + j['server'] + '\" \"true\"'
|
||||
if IO.popen(syscall).read.split(/\n+/) then
|
||||
ips = ips | IO.popen(syscall).read.split(/\n+/)
|
||||
end;
|
||||
else
|
||||
ips = ips.push(j['server']).uniq
|
||||
end;
|
||||
end;
|
||||
else
|
||||
ips = ips.push(j['server']).uniq
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
#Add ip skip
|
||||
if ips and not ips.empty? then
|
||||
ips.each do
|
||||
|ip|
|
||||
if ip and ip =~ reg then
|
||||
if firewall_v == 'nft' then
|
||||
syscall = 'nft add element inet fw4 localnetwork { \"' + ip + '\" } 2>/dev/null'
|
||||
system(syscall)
|
||||
else
|
||||
syscall = 'ipset add localnetwork \"' + ip + '\" 2>/dev/null'
|
||||
system(syscall)
|
||||
end;
|
||||
elsif ip and ip =~ reg6 then
|
||||
if firewall_v == 'nft' then
|
||||
syscall = 'nft add element inet fw4 localnetwork6 { \"' + ip + '\" } 2>/dev/null'
|
||||
system(syscall)
|
||||
else
|
||||
syscall = 'ipset add localnetwork6 \"' + ip + '\" 2>/dev/null'
|
||||
system(syscall)
|
||||
#Add ip skip
|
||||
if ips and not ips.empty? then
|
||||
ips.each do
|
||||
|ip|
|
||||
if ip and ip =~ reg then
|
||||
if firewall_v == 'nft' then
|
||||
syscall = 'nft add element inet fw4 localnetwork { \"' + ip + '\" } 2>/dev/null'
|
||||
system(syscall)
|
||||
else
|
||||
syscall = 'ipset add localnetwork \"' + ip + '\" 2>/dev/null'
|
||||
system(syscall)
|
||||
end;
|
||||
elsif ip and ip =~ reg6 then
|
||||
if firewall_v == 'nft' then
|
||||
syscall = 'nft add element inet fw4 localnetwork6 { \"' + ip + '\" } 2>/dev/null'
|
||||
system(syscall)
|
||||
else
|
||||
syscall = 'ipset add localnetwork6 \"' + ip + '\" 2>/dev/null'
|
||||
system(syscall)
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
}.join;
|
||||
rescue Exception => e
|
||||
puts '${LOGTIME} Error: Set Proxies Address Skip Failed,【' + e.message + '】';
|
||||
end" >> $LOG_FILE
|
||||
}.join;
|
||||
rescue Exception => e
|
||||
puts '${LOGTIME} Error: Set Proxies Address Skip Failed,【' + e.message + '】';
|
||||
end" >> $LOG_FILE
|
||||
let SKIP_PROXY_ADDRESS++
|
||||
else
|
||||
let SKIP_PROXY_ADDRESS++
|
||||
fi
|
||||
fi
|
||||
|
||||
## DNS转发劫持
|
||||
if [ "$enable_redirect_dns" = "1" ]; then
|
||||
|
@ -333,16 +333,8 @@ yml_other_set()
|
||||
'PROCESS-NAME,transmission-qt,DIRECT',
|
||||
'PROCESS-NAME,uTorrent,DIRECT',
|
||||
'PROCESS-NAME,WebTorrent,DIRECT',
|
||||
'PROCESS-NAME,aria2c,DIRECT',
|
||||
'PROCESS-NAME,fdm,DIRECT',
|
||||
'PROCESS-NAME,Folx,DIRECT',
|
||||
'PROCESS-NAME,NetTransport,DIRECT',
|
||||
'PROCESS-NAME,qbittorrent,DIRECT',
|
||||
'PROCESS-NAME,Thunder,DIRECT',
|
||||
'PROCESS-NAME,Transmission,DIRECT',
|
||||
'PROCESS-NAME,transmission,DIRECT',
|
||||
'PROCESS-NAME,uTorrent,DIRECT',
|
||||
'PROCESS-NAME,WebTorrent,DIRECT',
|
||||
'PROCESS-NAME,WebTorrent Helper,DIRECT',
|
||||
'PROCESS-NAME,v2ray,DIRECT',
|
||||
'PROCESS-NAME,ss-local,DIRECT',
|
||||
@ -353,6 +345,7 @@ yml_other_set()
|
||||
'PROCESS-NAME,trojan-go,DIRECT',
|
||||
'PROCESS-NAME,xray,DIRECT',
|
||||
'PROCESS-NAME,hysteria,DIRECT',
|
||||
'PROCESS-NAME,singbox,DIRECT',
|
||||
'PROCESS-NAME,UUBooster,DIRECT',
|
||||
'PROCESS-NAME,uugamebooster,DIRECT',
|
||||
'DST-PORT,80,' + common_port_group,
|
||||
|
Loading…
Reference in New Issue
Block a user