mirror of
https://github.com/roacn/openwrt-packages.git
synced 2025-01-07 03:16:45 +08:00
✨ Sync 2024-03-12 00:24
This commit is contained in:
parent
6d818b1e2b
commit
6ca2d944e1
@ -1,15 +1,18 @@
|
||||
# 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
|
||||
|
||||
PKG_VERSION:=2.0.2
|
||||
PKG_RELEASE:=20230718
|
||||
PKG_VERSION:=2.1.0
|
||||
PKG_RELEASE:=20240311
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
|
@ -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,4 +1,4 @@
|
||||
#
|
||||
|
||||
# Copyright (C) 2020-2021 sirpdboy <herboy2008@gmail.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
@ -8,11 +8,11 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-netspeedtest
|
||||
|
||||
PKG_VERSION:=2.2.1
|
||||
PKG_RELEASE:=20240307
|
||||
PKG_VERSION:=2.2.2
|
||||
PKG_RELEASE:=20240311
|
||||
|
||||
LUCI_TITLE:=LuCI Support for netspeedtest
|
||||
LUCI_DEPENDS:=+python3 +iperf3-ssl +homebox +ca-certificates
|
||||
LUCI_DEPENDS:=+python3 +iperf3-ssl +homebox
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_MAINTAINER:=<https://github.com/sirpdboy/netspeedtest>
|
||||
|
||||
|
@ -6,7 +6,7 @@ local o,s,e
|
||||
o = Map("netspeedtest", "<font color='green'>" .. translate("Net Speedtest") .."</font>",translate( "Network speed diagnosis test (including intranet and extranet)<br/>For specific usage, see:") ..translate("<a href=\'https://github.com/sirpdboy/netspeedtest.git' target=\'_blank\'>GitHub @sirpdboy/netspeedtest</a>") )
|
||||
o:section(SimpleSection).template = "netspeedtest/speedtestiperf3_status"
|
||||
|
||||
s = o:section(TypedSection, "netspeedtest", translate('Lan Speedtest Iperf3'))
|
||||
s = o:section(TypedSection, "speedtestiperf3", translate('Lan Speedtest Iperf3'))
|
||||
s.addremove=false
|
||||
s.anonymous=true
|
||||
|
||||
|
@ -6,7 +6,7 @@ m = Map("netspeedtest", "<font color='green'>" .. translate("Net Speedtest") .."
|
||||
s = m:section(TypedSection, "netspeedtest", translate('Lan Speedtest Web'))
|
||||
s.anonymous = true
|
||||
|
||||
o=s:option(Flag,"enabled",translate("Enable"))
|
||||
o=s:option(Flag,"enabled",translate("Enable Homebox service"))
|
||||
o.default=0
|
||||
|
||||
o = s:option(DummyValue, '', '')
|
||||
|
@ -7,6 +7,11 @@ o = Map("netspeedtest", "<font color='green'>" .. translate("Net Speedtest") .."
|
||||
t=o:section(TypedSection,"speedtestwan",translate("Broadband speed test"))
|
||||
t.anonymous=true
|
||||
|
||||
e = t:option(ListValue, 'speedtest_cli', translate('client version selection'))
|
||||
e:value("0",translate("ookla-speedtest-cli"))
|
||||
e:value("1",translate("python3-speedtest-cli"))
|
||||
e.default = "1"
|
||||
|
||||
e = t:option(DummyValue, '', '')
|
||||
e.rawhtml = true
|
||||
e.template ='netspeedtest/speedtestwan'
|
||||
|
@ -72,7 +72,7 @@
|
||||
<div class="cbi-value" >
|
||||
<label class="cbi-value-title"><%:iperf3 commands reference%></label>
|
||||
<div class="cbi-value-field">
|
||||
<%:-c, --client <host> ..............run in client mode, connecting to <host>%><br />
|
||||
<%:-c, --client host ................run in client mode, connecting to host%><br />
|
||||
<%:-s, --server .....................run in server mode%><br />
|
||||
<%:-u, --udp ........................use UDP rather than TCP%><br />
|
||||
<%:-b, --bandwidth ..<number>[KMG]...target bandwidth in bits/sec (0 for unlimited)%><br />
|
||||
|
@ -17,21 +17,51 @@
|
||||
<span id="wanspeedtest-output"></span>
|
||||
</fieldset>
|
||||
<script type="text/javascript">
|
||||
const RUN_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","speedtestrun")%>';
|
||||
function run(btn) {
|
||||
function run(btn) {
|
||||
|
||||
const RUN_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","speedtestwanrun")%>';
|
||||
const S_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","speedtestwan")%>';
|
||||
var sid='speedtestwan'
|
||||
var opt={
|
||||
base:"cbid.netspeedtest."+sid,
|
||||
get:function(opt){
|
||||
var id=this.base+'.'+opt;
|
||||
var obj=document.getElementsByName(id)[0] || document.getElementsByClassName(id)[0] || document.getElementById(id)
|
||||
if (obj){
|
||||
return obj;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
},
|
||||
getlist:function(opt){
|
||||
var id=this.base+'.'+opt;
|
||||
var objs=document.getElementsByName(id) || document.getElementsByClassName(id);
|
||||
var ret=[];
|
||||
if (objs){
|
||||
for (var i=0;i < objs.length;i++){
|
||||
ret[i]=objs[i].value;
|
||||
}
|
||||
}else{
|
||||
alert("<%:Fatal on get option,please help in debug%>:"+opt);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
var legend=document.getElementById('wanspeedtest-legend');
|
||||
var output=document.getElementById('wanspeedtest-output');
|
||||
btn.value='<%:Waiting (executing)...%>';
|
||||
btn.disabled=true;
|
||||
var cli=opt.get("speedtest_cli").value;
|
||||
console.log(cli);
|
||||
legend.parentNode.style.display = 'block';
|
||||
legend.style.display = 'inline';
|
||||
output.innerHTML =
|
||||
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
|
||||
'<%:Network speed test, please wait...%>'
|
||||
;
|
||||
legend.parentNode.style.display = 'block';
|
||||
legend.style.display = 'inline';
|
||||
XHR.get(RUN_URL,null,
|
||||
function(x)
|
||||
{
|
||||
|
||||
XHR.get(RUN_URL, { cli: cli },
|
||||
(x) =>{
|
||||
if (x.responseText)
|
||||
{
|
||||
legend.style.display = 'none';
|
||||
|
@ -28,6 +28,9 @@ msgstr "本地测速网页版"
|
||||
msgid "Running state"
|
||||
msgstr "运行状态"
|
||||
|
||||
msgid "Enable Homebox service"
|
||||
msgstr "启用homebox服务"
|
||||
|
||||
msgid "The Iperf3 service is running."
|
||||
msgstr "iperf3服务已启动"
|
||||
|
||||
|
@ -28,6 +28,9 @@ msgstr "本地测速网页版"
|
||||
msgid "Running state"
|
||||
msgstr "运行状态"
|
||||
|
||||
msgid "Enable Homebox service"
|
||||
msgstr "启用homebox服务"
|
||||
|
||||
msgid "The Iperf3 service is running."
|
||||
msgstr "iperf3服务已启动"
|
||||
|
||||
|
@ -12,4 +12,4 @@ config speedtestwan 'speedtestwan'
|
||||
|
||||
config speedtestport 'speedtestport'
|
||||
option sport '443'
|
||||
option sdomain 'www.taobao.com'
|
||||
option sdomain 'www.taobao.com'
|
@ -10,7 +10,7 @@ START=99
|
||||
USE_PROCD=1
|
||||
|
||||
PROG=/usr/bin/homebox
|
||||
EXTRA_COMMANDS="nstest"
|
||||
EXTRA_COMMANDS="wantest"
|
||||
|
||||
TMP_T=/var/netspeedtest_nstest.tmp
|
||||
BINSPEEDTEST='/usr/bin/speedtest'
|
||||
@ -39,26 +39,84 @@ echone() {
|
||||
}
|
||||
|
||||
|
||||
nstest() {
|
||||
wantest() {
|
||||
[ -f $LOCK ] && exit
|
||||
limit_log $LOG 500
|
||||
init_log $LOG
|
||||
touch $LOCK
|
||||
echo -ne "\n ——————————speedtest测速"—————————— >> $LOG
|
||||
/usr/bin/speedtest --share > $TMP_T
|
||||
TESTMODE=$1
|
||||
BINTEMP=$(git_bin_handle $TESTMODE)
|
||||
# [ -n "$BINTEMP" ] || return
|
||||
# echone "\n BINTEMP: $BINTEMP "
|
||||
case $TESTMODE in
|
||||
0)
|
||||
echone "\n —————ookla-speedtest测速$TESTMODE—————"
|
||||
info=$($BINTEMP > $TMP_T )
|
||||
#$BINTEMP > $TMP_T
|
||||
echo -ne "\n 测服信息:`cat $TMP_T | grep 'Server'| cut -c10- | awk -F: '{printf $2$3}'` 线路:`cat $TMP_T | grep 'ISP' | awk -F: '{printf $2}' ` 延时:`cat $TMP_T | grep 'Latency' | awk -F: '{printf $2}' | awk -F '(' '{printf $1}'`" >> $LOG
|
||||
echo -ne "\n 下行速率:`cat $TMP_T | grep 'Download' |awk -F: '{printf $2}' | awk -F '(' '{printf $1}'` --" >> $LOG
|
||||
echo -ne "-- 上行速率:`cat $TMP_T | grep 'Upload' |awk -F: '{printf $2}' | awk -F '(' '{printf $1}'`" >> $LOG
|
||||
echo -ne "\n 测速结果图片链接:`cat $TMP_T | grep 'URL' | cut -c15-`" >> $LOG
|
||||
echo -ne "\n 测试时间: `date +%Y-%m-%d' '%H:%M:%S`" >> $LOG
|
||||
echo -ne "\n ————————————————————\n" >> $LOG
|
||||
# cat $TMP_T | grep 'URL' | cut -c15- > /var/speedtesturl.tmp
|
||||
echo -ne "`cat $TMP_T | grep 'URL' | cut -c15- `"
|
||||
;;
|
||||
*)
|
||||
echo -ne "\n —————python3-speedtest测速$TESTMODE—————" >> $LOG
|
||||
$BINTEMP > $TMP_T
|
||||
echo -ne "\n 测服信息:$(cat $TMP_T | grep 'Hosted by'| cut -c10- | awk -F: '{printf $1}') 延时:$(cat $TMP_T | grep 'Hosted by' | awk -F: '{printf $2}')" >> $LOG
|
||||
echo -ne "\n 下行速率:$(cat $TMP_T | grep 'Download:' |awk -F: '{printf $2}' )" >> $LOG
|
||||
echo -ne " ---- 上行速率:$(cat $TMP_T | grep 'Upload:' |awk -F: '{printf $2}' )" >> $LOG
|
||||
echo -ne "\n 测试结果图片链接:$(cat $TMP_T | grep 'results:' | cut -c16- ) \n" >> $LOG
|
||||
echo -ne "\n 测试时间:`date +%Y-%m-%d" "%H:%M:%S` \n" >> $LOG
|
||||
echo -ne " ——————————————————————————————\n" >> $LOG
|
||||
echo -ne "\n 测试结果图片链接:$(cat $TMP_T | grep 'results:' | cut -c16- )" >> $LOG
|
||||
echo -ne "\n 测试时间:`date +%Y-%m-%d" "%H:%M:%S`" >> $LOG
|
||||
echo -ne "\n ————————————————————\n" >> $LOG
|
||||
echo -ne $(cat $TMP_T | grep 'results:' | cut -c16- )
|
||||
|
||||
;;
|
||||
esac
|
||||
rm -f $LOCK
|
||||
}
|
||||
|
||||
|
||||
git_bin_handle()
|
||||
{
|
||||
case $1 in
|
||||
|
||||
0)
|
||||
TMPDIR=/var/netspeedtest
|
||||
BINSPEEDTEST=$TMPDIR/speedtest
|
||||
[ ! -d $TMPDIR ] && mkdir -p $TMPDIR 2>/dev/null
|
||||
if [ -x "$BINSPEEDTEST" ]; then
|
||||
chmod 755 $BINSPEEDTEST >/dev/null 2>&1
|
||||
echo "$BINSPEEDTEST --accept-gdpr --accept-license --progress=no"
|
||||
else
|
||||
ooklaurl=`curl --connect-timeout 5 -m 60 -sSL 'https://www.speedtest.net/apps/cli' | grep 'Download for Linux' | sed 's|<|\n<|g' | sed -n '/Download for Linux/,/<\/div>/p' | sed -En "s|.*<a href=\"([^\"]+)\">x86_64|\1|p" `
|
||||
[ -n "$ooklaurl" ] && curl -sSL $ooklaurl | tar -xvz -C /tmp >/dev/null 2>&1 || return
|
||||
mv /tmp/speedtest $BINSPEEDTEST >/dev/null 2>&1
|
||||
chmod 755 $BINSPEEDTEST >/dev/null 2>&1
|
||||
[ -x "$BINSPEEDTEST" ] && echo "$BINSPEEDTEST --accept-gdpr --accept-license --progress=no"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
BINSPEEDTEST='/usr/bin/speedtest'
|
||||
[ -x "$BINSPEEDTEST" ] && echo "$BINSPEEDTEST --share"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
speedtest_start(){
|
||||
case $1 in
|
||||
0)
|
||||
speedtest_start_ookla $2 ;;
|
||||
*)
|
||||
speedtest_start_cli $2 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
tcptest(){
|
||||
NDATA=`date +%Y-%m-%d' '%H:%M:%S`
|
||||
echo -ne "\n $NDATA 服务器:$1 ---- 端口:$2 ---- TCP延时:$3 Ms \n" >> $LOG
|
||||
echo -ne "\n $NDATA 服务器:$1 ---- 端口:$2 ---- TCP延时:$3 ms \n" >> $LOG
|
||||
}
|
||||
|
||||
get_config() {
|
||||
|
98
luci-app-netspeedtest/root/lib/functions/netspeedtest.sh
Normal file
98
luci-app-netspeedtest/root/lib/functions/netspeedtest.sh
Normal file
@ -0,0 +1,98 @@
|
||||
################################################################################
|
||||
# (netspeedtest) functions.sh
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 2 as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# Copyright (C) 2019-2024 The Sirpdboy Team <herboy2008@gmail.com>
|
||||
# . /lib/netspeedtest/functions.sh
|
||||
################################################################################
|
||||
|
||||
# tmp speedtest
|
||||
TMP_TEST=/var/netspeedtest.tmp
|
||||
MAX_LOG=200
|
||||
LOG=/var/log/netspeedtest.log
|
||||
limit_log() {
|
||||
local logf=$1
|
||||
local max=$2
|
||||
[ ! -f "$logf" ] && return
|
||||
sc=${max:-$MAX_LOG}
|
||||
local count=$(grep -c "" $logf)
|
||||
if [ $count -gt $sc ];then
|
||||
let count=count-$sc
|
||||
sed -i "1,$count d" $logf
|
||||
fi
|
||||
}
|
||||
|
||||
init_log() {
|
||||
local logf=$1
|
||||
[ ! -f "$logf" ] && echo "" > $logf
|
||||
}
|
||||
|
||||
echone() {
|
||||
echo -ne $* >> $LOG
|
||||
}
|
||||
|
||||
|
||||
git_bin_handle()
|
||||
{
|
||||
case $1 in
|
||||
|
||||
0)
|
||||
TMPDIR=/var/netspeedtest
|
||||
BINSPEEDTEST=$TMPDIR/speedtest
|
||||
[ ! -d $TMPDIR ] && mkdir -p $TMPDIR 2>/dev/null
|
||||
if [ -x "$BINSPEEDTEST" ]; then
|
||||
chmod 755 $BINSPEEDTEST >/dev/null 2>&1
|
||||
echo "$BINSPEEDTEST --accept-gdpr --accept-license --progress=no"
|
||||
else
|
||||
ooklaurl=`curl --connect-timeout 5 -m 60 -sSL 'https://www.speedtest.net/apps/cli' | grep 'Download for Linux' | sed 's|<|\n<|g' | sed -n '/Download for Linux/,/<\/div>/p' | sed -En "s|.*<a href=\"([^\"]+)\">x86_64|\1|p" `
|
||||
[ -n "$ooklaurl" ] && curl -sSL $ooklaurl | tar -xvz -C /tmp >/dev/null 2>&1 || return
|
||||
mv /tmp/speedtest $BINSPEEDTEST >/dev/null 2>&1
|
||||
chmod 755 $BINSPEEDTEST >/dev/null 2>&1
|
||||
[ -x "$BINSPEEDTEST" ] && echo "$BINSPEEDTEST --accept-gdpr --accept-license --progress=no"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
BINSPEEDTEST='/usr/bin/speedtest'
|
||||
[ -x "$BINSPEEDTEST" ] && echo "$BINSPEEDTEST --share"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
speedtest_start(){
|
||||
case $1 in
|
||||
0)
|
||||
speedtest_start_ookla $2 ;;
|
||||
*)
|
||||
speedtest_start_cli $2 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
speedtest_start_ookla(){
|
||||
echone "\n ookla-speedtest测速"
|
||||
info=$($1 > $TMP_TEST ) >/dev/null 2>&1
|
||||
echone "\n info:$info ----------------- "
|
||||
echone "\n 测服信息:`cat $TMP_TEST | grep 'Server'| cut -c10- | awk -F: '{printf $2$3}'` 线路:`cat $TMP_TEST | grep 'ISP' | awk -F: '{printf $2}' ` 延时:`cat $TMP_TEST | grep 'Latency' | awk -F: '{printf $2}' | awk -F '(' '{printf $1}'`"
|
||||
echone "\n 下行速率:`cat $TMP_TEST | grep 'Download' |awk -F: '{printf $2}' | awk -F '(' '{printf $1}'` --"
|
||||
echone "-- 上行速率:`cat $TMP_TEST | grep 'Upload' |awk -F: '{printf $2}' | awk -F '(' '{printf $1}'`"
|
||||
echo -ne "\n 测速结果图片链接:`cat $TMP_TEST | grep 'URL' | cut -c15-`" >> $LOG
|
||||
echone "\n 测试时间: `date +%Y-%m-%d' '%H:%M:%S`"
|
||||
echone "\n ————————————————————————————\n"
|
||||
cat $TMP_TEST | grep 'URL' | cut -c15- > /var/speedtesturl.tmp
|
||||
echo -ne "`cat $TMP_TEST | grep 'URL' | cut -c15- `"
|
||||
}
|
||||
|
||||
speedtest_start_cli(){
|
||||
echone "\n python3-speedtest测速"
|
||||
info=$($1 > $TMP_TEST ) >/dev/null 2>&1
|
||||
echone "\n 测服信息:`cat $TMP_TEST | grep 'Hosted by'| cut -c10- | awk -F: '{printf $1}'` 延时:`cat $TMP_TEST | grep 'Hosted by' | awk -F: '{printf $2}'`"
|
||||
echone "\n 下行速率:`cat $TMP_TEST | grep 'Download:' |awk -F: '{printf $2}' ` --"
|
||||
echone "-- 上行速率:`cat $TMP_TEST | grep 'Upload:' |awk -F: '{printf $2}' `"
|
||||
echo -ne "\n 测速结果图片链接:`cat $TMP_TEST | grep 'results' | cut -c16-`" >> $LOG
|
||||
echone "\n 测试时间: `date +%Y-%m-%d' '%H:%M:%S`"
|
||||
echone "\n ————————————————————————————\n"
|
||||
cat $TMP_TEST | grep 'results:' | cut -c16- > /var/speedtesturl.tmp
|
||||
echo -ne "`cat $TMP_TEST | grep 'results:' | cut -c16-`"
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall
|
||||
PKG_VERSION:=4.75-8
|
||||
PKG_VERSION:=4.75-9
|
||||
PKG_RELEASE:=
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
|
@ -192,20 +192,20 @@ function status()
|
||||
-- local dns_mode = ucic:get(appname, "@global[0]", "dns_mode")
|
||||
local e = {}
|
||||
e.dns_mode_status = luci.sys.call("netstat -apn | grep ':15353 ' >/dev/null") == 0
|
||||
e.haproxy_status = luci.sys.call(string.format("top -bn1 | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null", appname)) == 0
|
||||
e["tcp_node_status"] = luci.sys.call("top -bn1 | grep -v 'grep' | grep '/tmp/etc/passwall/bin/' | grep -v '_acl_' | grep 'TCP' >/dev/null") == 0
|
||||
e.haproxy_status = luci.sys.call(string.format("/bin/busybox top -bn1 | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null", appname)) == 0
|
||||
e["tcp_node_status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v 'grep' | grep '/tmp/etc/passwall/bin/' | grep -v '_acl_' | grep 'TCP' >/dev/null") == 0
|
||||
|
||||
if (ucic:get(appname, "@global[0]", "udp_node") or "nil") == "tcp" then
|
||||
e["udp_node_status"] = e["tcp_node_status"]
|
||||
else
|
||||
e["udp_node_status"] = luci.sys.call("top -bn1 | grep -v 'grep' | grep '/tmp/etc/passwall/bin/' | grep -v '_acl_' | grep 'UDP' >/dev/null") == 0
|
||||
e["udp_node_status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v 'grep' | grep '/tmp/etc/passwall/bin/' | grep -v '_acl_' | grep 'UDP' >/dev/null") == 0
|
||||
end
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
function haproxy_status()
|
||||
local e = luci.sys.call(string.format("top -bn1 | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null", appname)) == 0
|
||||
local e = luci.sys.call(string.format("/bin/busybox top -bn1 | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null", appname)) == 0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
@ -215,12 +215,12 @@ function socks_status()
|
||||
local index = luci.http.formvalue("index")
|
||||
local id = luci.http.formvalue("id")
|
||||
e.index = index
|
||||
e.socks_status = luci.sys.call(string.format("top -bn1 | grep -v 'grep' | grep '/tmp/etc/passwall/bin/' | grep -v '_acl_' | grep '%s' | grep 'SOCKS_' > /dev/null", id)) == 0
|
||||
e.socks_status = luci.sys.call(string.format("/bin/busybox top -bn1 | grep -v 'grep' | grep '/tmp/etc/passwall/bin/' | grep -v '_acl_' | grep '%s' | grep 'SOCKS_' > /dev/null", id)) == 0
|
||||
local use_http = ucic:get(appname, id, "http_port") or 0
|
||||
e.use_http = 0
|
||||
if tonumber(use_http) > 0 then
|
||||
e.use_http = 1
|
||||
e.http_status = luci.sys.call(string.format("top -bn1 | grep -v 'grep' | grep '/tmp/etc/passwall/bin/' | grep -v '_acl_' | grep '%s' | grep -E 'HTTP_|HTTP2SOCKS' > /dev/null", id)) == 0
|
||||
e.http_status = luci.sys.call(string.format("/bin/busybox top -bn1 | grep -v 'grep' | grep '/tmp/etc/passwall/bin/' | grep -v '_acl_' | grep '%s' | grep -E 'HTTP_|HTTP2SOCKS' > /dev/null", id)) == 0
|
||||
end
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
@ -385,7 +385,7 @@ end
|
||||
function server_user_status()
|
||||
local e = {}
|
||||
e.index = luci.http.formvalue("index")
|
||||
e.status = luci.sys.call(string.format("top -bn1 | grep -v 'grep' | grep '%s/bin/' | grep -i '%s' >/dev/null", appname .. "_server", luci.http.formvalue("id"))) == 0
|
||||
e.status = luci.sys.call(string.format("/bin/busybox top -bn1 | grep -v 'grep' | grep '%s/bin/' | grep -i '%s' >/dev/null", appname .. "_server", luci.http.formvalue("id"))) == 0
|
||||
http_write_json(e)
|
||||
end
|
||||
|
||||
|
@ -190,7 +190,6 @@ o:value("disable", translate("No patterns are used"))
|
||||
o:value("default", translate("Default"))
|
||||
o.validate = port_validate
|
||||
o:value("default", translate("Use global config") .. "(" .. TCP_PROXY_DROP_PORTS .. ")")
|
||||
o:depends({ tcp_node = "", ['!reverse'] = true })
|
||||
|
||||
---- UDP Proxy Drop Ports
|
||||
local UDP_PROXY_DROP_PORTS = uci:get(appname, "@global_forwarding[0]", "udp_proxy_drop_ports")
|
||||
@ -200,11 +199,10 @@ o:value("disable", translate("No patterns are used"))
|
||||
o:value("default", translate("Use global config") .. "(" .. UDP_PROXY_DROP_PORTS .. ")")
|
||||
o:value("80,443", translate("QUIC"))
|
||||
o.validate = port_validate
|
||||
o:depends({ udp_node = "", ['!reverse'] = true })
|
||||
|
||||
---- TCP Redir Ports
|
||||
local TCP_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "tcp_redir_ports")
|
||||
o = s:option(Value, "tcp_redir_ports", translate("TCP Redir Ports"))
|
||||
o = s:option(Value, "tcp_redir_ports", translate("TCP Redir Ports"), translatef("Only work with using the %s node.", "TCP"))
|
||||
o.default = "default"
|
||||
o:value("default", translate("Use global config") .. "(" .. TCP_REDIR_PORTS .. ")")
|
||||
o:value("1:65535", translate("All"))
|
||||
@ -212,17 +210,15 @@ o:value("80,443", "80,443")
|
||||
o:value("80:65535", "80 " .. translate("or more"))
|
||||
o:value("1:443", "443 " .. translate("or less"))
|
||||
o.validate = port_validate
|
||||
o:depends({ tcp_node = "", ['!reverse'] = true })
|
||||
|
||||
---- UDP Redir Ports
|
||||
local UDP_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "udp_redir_ports")
|
||||
o = s:option(Value, "udp_redir_ports", translate("UDP Redir Ports"))
|
||||
o = s:option(Value, "udp_redir_ports", translate("UDP Redir Ports"), translatef("Only work with using the %s node.", "UDP"))
|
||||
o.default = "default"
|
||||
o:value("default", translate("Use global config") .. "(" .. UDP_REDIR_PORTS .. ")")
|
||||
o:value("1:65535", translate("All"))
|
||||
o:value("53", "53")
|
||||
o.validate = port_validate
|
||||
o:depends({ udp_node = "", ['!reverse'] = true })
|
||||
|
||||
o = s:option(Flag, "use_direct_list", translatef("Use %s", translate("Direct List")))
|
||||
o.default = "1"
|
||||
|
@ -197,7 +197,7 @@ local function start()
|
||||
end
|
||||
|
||||
local function stop()
|
||||
cmd(string.format("top -bn1 | grep -v 'grep' | grep '%s/' | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1", CONFIG_PATH))
|
||||
cmd(string.format("/bin/busybox top -bn1 | grep -v 'grep' | grep '%s/' | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1", CONFIG_PATH))
|
||||
if nft_flag == "0" then
|
||||
ipt("-D INPUT -j PSW-SERVER 2>/dev/null")
|
||||
ipt("-F PSW-SERVER 2>/dev/null")
|
||||
|
@ -1590,3 +1590,6 @@ msgstr "落地节点"
|
||||
|
||||
msgid "Only support a layer of proxy."
|
||||
msgstr "仅支持一层代理。"
|
||||
|
||||
msgid "Only work with using the %s node."
|
||||
msgstr "与使用 %s 节点时生效。"
|
||||
|
@ -1360,7 +1360,7 @@ acl_app() {
|
||||
mkdir -p $TMP_ACL_PATH/$sid
|
||||
echo -e "${rule_list}" | sed '/^$/d' > $TMP_ACL_PATH/$sid/rule_list
|
||||
|
||||
use_global_config=${use_global_config}
|
||||
use_global_config=${use_global_config:-0}
|
||||
tcp_node=${tcp_node:-nil}
|
||||
udp_node=${udp_node:-nil}
|
||||
use_direct_list=${use_direct_list:-1}
|
||||
@ -1379,7 +1379,7 @@ acl_app() {
|
||||
[ "$v2ray_dns_mode" = "doh" ] && remote_dns=${remote_dns_doh:-https://1.1.1.1/dns-query}
|
||||
}
|
||||
|
||||
[ "${use_global_config}" = "1" ] & {
|
||||
[ "${use_global_config}" = "1" ] && {
|
||||
tcp_node="default"
|
||||
udp_node="default"
|
||||
}
|
||||
|
@ -206,23 +206,20 @@ load_acl() {
|
||||
[ "$udp_proxy_drop_ports" = "default" ] && udp_proxy_drop_ports=$UDP_PROXY_DROP_PORTS
|
||||
[ "$tcp_redir_ports" = "default" ] && tcp_redir_ports=$TCP_REDIR_PORTS
|
||||
[ "$udp_redir_ports" = "default" ] && udp_redir_ports=$UDP_REDIR_PORTS
|
||||
|
||||
[ "${use_global_config}" = "1" ] & {
|
||||
tcp_node="default"
|
||||
udp_node="default"
|
||||
}
|
||||
|
||||
tcp_node_remark=$(config_n_get $TCP_NODE remarks)
|
||||
udp_node_remark=$(config_n_get $UDP_NODE remarks)
|
||||
|
||||
[ -s "${TMP_ACL_PATH}/${sid}/var_tcp_node" ] && tcp_node=$(cat ${TMP_ACL_PATH}/${sid}/var_tcp_node)
|
||||
[ -s "${TMP_ACL_PATH}/${sid}/var_udp_node" ] && udp_node=$(cat ${TMP_ACL_PATH}/${sid}/var_udp_node)
|
||||
[ -s "${TMP_ACL_PATH}/${sid}/var_tcp_port" ] && tcp_port=$(cat ${TMP_ACL_PATH}/${sid}/var_tcp_port)
|
||||
[ -s "${TMP_ACL_PATH}/${sid}/var_udp_port" ] && udp_port=$(cat ${TMP_ACL_PATH}/${sid}/var_udp_port)
|
||||
|
||||
[ "$udp_node" == "default" ] && [ "$UDP_NODE" = "nil" ] && [ "$TCP_UDP" = "1" ] && udp_node=$TCP_NODE
|
||||
[ -n "$tcp_node" ] && [ "$tcp_node" != "default" ] && tcp_node_remark=$(config_n_get $tcp_node remarks)
|
||||
[ -n "$udp_node" ] && [ "$udp_node" != "default" ] && udp_node_remark=$(config_n_get $udp_node remarks)
|
||||
|
||||
[ "$tcp_node" != "nil" ] && tcp_node_remark=$(config_n_get $tcp_node remarks)
|
||||
[ "$udp_node" != "nil" ] && udp_node_remark=$(config_n_get $udp_node remarks)
|
||||
[ "$udp_node" == "tcp" ] && udp_node_remark=$tcp_node_remark
|
||||
|
||||
[ "${use_global_config}" = "1" ] && {
|
||||
tcp_node_remark=$(config_n_get $TCP_NODE remarks)
|
||||
udp_node_remark=$(config_n_get $UDP_NODE remarks)
|
||||
}
|
||||
|
||||
for i in $(cat ${TMP_ACL_PATH}/${sid}/rule_list); do
|
||||
if [ -n "$(echo ${i} | grep '^iprange:')" ]; then
|
||||
_iprange=$(echo ${i} | sed 's#iprange:##g')
|
||||
|
@ -241,23 +241,20 @@ load_acl() {
|
||||
[ "$udp_proxy_drop_ports" = "default" ] && udp_proxy_drop_ports=$UDP_PROXY_DROP_PORTS
|
||||
[ "$tcp_redir_ports" = "default" ] && tcp_redir_ports=$TCP_REDIR_PORTS
|
||||
[ "$udp_redir_ports" = "default" ] && udp_redir_ports=$UDP_REDIR_PORTS
|
||||
|
||||
[ "${use_global_config}" = "1" ] & {
|
||||
tcp_node="default"
|
||||
udp_node="default"
|
||||
}
|
||||
|
||||
tcp_node_remark=$(config_n_get $TCP_NODE remarks)
|
||||
udp_node_remark=$(config_n_get $UDP_NODE remarks)
|
||||
[ -s "${TMP_ACL_PATH}/${sid}/var_tcp_node" ] && tcp_node=$(cat ${TMP_ACL_PATH}/${sid}/var_tcp_node)
|
||||
[ -s "${TMP_ACL_PATH}/${sid}/var_udp_node" ] && udp_node=$(cat ${TMP_ACL_PATH}/${sid}/var_udp_node)
|
||||
[ -s "${TMP_ACL_PATH}/${sid}/var_tcp_port" ] && tcp_port=$(cat ${TMP_ACL_PATH}/${sid}/var_tcp_port)
|
||||
[ -s "${TMP_ACL_PATH}/${sid}/var_udp_port" ] && udp_port=$(cat ${TMP_ACL_PATH}/${sid}/var_udp_port)
|
||||
|
||||
[ "$udp_node" == "default" ] && [ "$UDP_NODE" = "nil" ] && [ "$TCP_UDP" = "1" ] && udp_node=$TCP_NODE
|
||||
[ -n "$tcp_node" ] && [ "$tcp_node" != "default" ] && tcp_node_remark=$(config_n_get $tcp_node remarks)
|
||||
[ -n "$udp_node" ] && [ "$udp_node" != "default" ] && udp_node_remark=$(config_n_get $udp_node remarks)
|
||||
|
||||
[ "$tcp_node" != "nil" ] && tcp_node_remark=$(config_n_get $tcp_node remarks)
|
||||
[ "$udp_node" != "nil" ] && udp_node_remark=$(config_n_get $udp_node remarks)
|
||||
[ "$udp_node" == "tcp" ] && udp_node_remark=$tcp_node_remark
|
||||
|
||||
[ "${use_global_config}" = "1" ] && {
|
||||
tcp_node_remark=$(config_n_get $TCP_NODE remarks)
|
||||
udp_node_remark=$(config_n_get $UDP_NODE remarks)
|
||||
}
|
||||
|
||||
for i in $(cat ${TMP_ACL_PATH}/${sid}/rule_list); do
|
||||
if [ -n "$(echo ${i} | grep '^iprange:')" ]; then
|
||||
_iprange=$(echo ${i} | sed 's#iprange:##g')
|
||||
|
Loading…
Reference in New Issue
Block a user