luci: auto switch interval support seconds

It is not recommended to set up too small.
This commit is contained in:
xiaorouji 2023-08-25 00:19:02 +08:00 committed by sbwml
parent 0346003369
commit 1e89348445
3 changed files with 11 additions and 12 deletions

View File

@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall2
PKG_VERSION:=1.19-1
PKG_VERSION:=1.19-2
PKG_RELEASE:=
PKG_CONFIG_DEPENDS:= \

View File

@ -64,18 +64,18 @@ o = s:option(Flag, "enable_autoswitch", translate("Auto Switch"))
o.default = 0
o.rmempty = false
o = s:option(Value, "autoswitch_testing_time", translate("How often to test"), translate("Units:minutes"))
o.datatype = "uinteger"
o.default = 1
o = s:option(Value, "autoswitch_testing_time", translate("How often to test"), translate("Units:seconds"))
o.datatype = "min(10)"
o.default = 30
o:depends("enable_autoswitch", true)
o = s:option(Value, "autoswitch_connect_timeout", translate("Timeout seconds"), translate("Units:seconds"))
o.datatype = "uinteger"
o.datatype = "min(1)"
o.default = 3
o:depends("enable_autoswitch", true)
o = s:option(Value, "autoswitch_retry_num", translate("Timeout retry num"))
o.datatype = "uinteger"
o.datatype = "min(1)"
o.default = 1
o:depends("enable_autoswitch", true)
@ -105,12 +105,11 @@ o:depends("enable_autoswitch", true)
o = s:option(Value, "autoswitch_probe_url", translate("Probe URL"), translate("The URL used to detect the connection status."))
o.default = "https://www.google.com/generate_204"
o:depends("enable_autoswitch", true)
for k, v in pairs(nodes_table) do
if v.node_type == "normal" then
autoswitch_backup_node:value(v.id, v["remark"])
socks_node:value(v.id, v["remark"])
end
autoswitch_backup_node:value(v.id, v["remark"])
socks_node:value(v.id, v["remark"])
end
m:append(Template(appname .. "/socks_auto_switch/footer"))

View File

@ -156,7 +156,7 @@ start() {
LOCK_FILE=${LOCK_FILE_DIR}/${CONFIG}_socks_auto_switch_${id}.lock
main_node=$(config_n_get $id node nil)
socks_port=$(config_n_get $id port 0)
delay=$(config_n_get $id autoswitch_testing_time 1)
delay=$(config_n_get $id autoswitch_testing_time 30)
sleep 5s
connect_timeout=$(config_n_get $id autoswitch_connect_timeout 3)
retry_num=$(config_n_get $id autoswitch_retry_num 1)
@ -172,7 +172,7 @@ start() {
backup_node=$(echo $backup_node | tr -s ' ' '\n' | uniq | tr -s '\n' ' ')
test_auto_switch "$backup_node"
rm -f $LOCK_FILE
sleep ${delay}m
sleep ${delay}
done
}