diff --git a/dae/files/dae.init b/dae/files/dae.init index 974f4929..c407a9e5 100755 --- a/dae/files/dae.init +++ b/dae/files/dae.init @@ -43,35 +43,11 @@ update_cron() { } cleanup_netns() { - if ps w | grep -q "[/]usr/bin/daed run"; then - logger -t dae "skip dae runtime cleanup while daed is running" - return 0 - fi - - if ip link show "$DAE_HOST_IFACE" >/dev/null 2>&1; then - tc qdisc del dev "$DAE_HOST_IFACE" clsact 2>/dev/null || true - ip link del "$DAE_HOST_IFACE" 2>/dev/null || true - fi - - if ip link show "$DAE_PEER_IFACE" >/dev/null 2>&1; then - ip link del "$DAE_PEER_IFACE" 2>/dev/null || true - fi - - if [ -e "$DAENETNS" ]; then - ip netns del "$DAE_NETNS_NAME" 2>/dev/null || true - rm -f "$DAENETNS" 2>/dev/null || true - fi -} - -wait_dae_exit() { - local i - - for i in 1 2 3 4 5 6 7 8 9 10; do - ps w | grep -q "[/]usr/bin/dae run" || return 0 - sleep 1 - done - - return 1 + tc qdisc del dev "$DAE_HOST_IFACE" clsact 2>/dev/null || true + ip link del "$DAE_HOST_IFACE" 2>/dev/null || true + ip link del "$DAE_PEER_IFACE" 2>/dev/null || true + ip netns del "$DAE_NETNS_NAME" 2>/dev/null || true + rm -f "$DAENETNS" 2>/dev/null || true } hijack_resolv_conf() { @@ -146,14 +122,12 @@ start_service() { stop_service() { update_cron "remove" restore_resolv_conf + cleanup_netns } -service_stopped() { - if wait_dae_exit; then - cleanup_netns - else - logger -t dae "skip dae runtime cleanup because dae is still running" - fi +reload_service() { + stop + start } service_triggers() { diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile index 4f35f3f1..4e6231ea 100644 --- a/luci-app-passwall/Makefile +++ b/luci-app-passwall/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall -PKG_VERSION:=26.7.16 +PKG_VERSION:=26.7.24 PKG_RELEASE:=1 PKG_PO_VERSION:=$(PKG_VERSION) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/socks_config.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/socks_config.lua index 7427bbf6..bab7888c 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/socks_config.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/socks_config.lua @@ -150,7 +150,7 @@ o.datatype = "min(1)" o.default = 1 o:depends("enable_autoswitch", true) -o = s:option(Flag, "autoswitch_restore_switch", translate("Restore Switch"), translate("When detects main node is available, switch back to the main node.")) +o = s:option(Flag, "autoswitch_restore_switch", translate("Restore Switch"), translate("Immediately switch back to the main node when it becomes available.")) o:depends("enable_autoswitch", true) o = s:option(Value, "autoswitch_probe_url", translate("Probe URL"), translate("The URL used to detect the connection status.")) diff --git a/luci-app-passwall/po/zh-cn/passwall.po b/luci-app-passwall/po/zh-cn/passwall.po index 497c596f..340dc9d6 100644 --- a/luci-app-passwall/po/zh-cn/passwall.po +++ b/luci-app-passwall/po/zh-cn/passwall.po @@ -893,8 +893,8 @@ msgstr "备用节点的列表" msgid "Restore Switch" msgstr "恢复切换" -msgid "When detects main node is available, switch back to the main node." -msgstr "当检测到主节点可用时,切换回主节点。" +msgid "Immediately switch back to the main node when it becomes available." +msgstr "当主节点可用时,立即切换回主节点。" msgid "Add nodes to the standby node list by keywords" msgstr "通过关键字添加节点到备用节点列表" diff --git a/luci-app-passwall/root/usr/share/passwall/socks_auto_switch.sh b/luci-app-passwall/root/usr/share/passwall/socks_auto_switch.sh index 6ba3baad..b558a33d 100755 --- a/luci-app-passwall/root/usr/share/passwall/socks_auto_switch.sh +++ b/luci-app-passwall/root/usr/share/passwall/socks_auto_switch.sh @@ -125,7 +125,11 @@ test_auto_switch() { done # 如果没找到当前节点,或者当前节点是最后一个,就取第一个节点 [ -z "$new_node" ] && new_node="$first_node" - msg="切换到$([ "$now_node" = "$main_node" ] && echo 备用节点 || echo 下一个备用节点)检测!" + if [ "$new_node" = "$main_node" ]; then + msg="切换到主节点检测!" + else + msg="切换到$([ "$now_node" = "$main_node" ] && echo 备用节点 || echo 下一个备用节点)检测!" + fi else # 只有一个后备节点时,与主节点轮询 new_node=$([ "$now_node" = "$main_node" ] && echo "$b_nodes" || echo "$main_node") @@ -134,11 +138,6 @@ test_auto_switch() { echolog "Socks切换检测:端口[${socks_port}]【$(config_n_get $now_node type):[$(config_n_get $now_node remarks)]】异常,$msg" test_node ${new_node} if [ $? -eq 0 ]; then -# [ "$restore_switch" = "0" ] && { -# uci set $CONFIG.${id}.node=$new_node -# [ -z "$(echo $b_nodes | grep $main_node)" ] && uci add_list $CONFIG.${id}.autoswitch_backup_node=$main_node -# uci commit $CONFIG -# } check_process echolog "Socks切换检测:端口[${socks_port}]【$(config_n_get $new_node type):[$(config_n_get $new_node remarks)]】正常,切换到此节点!" NO_REC_PROCESS=1 $APP_FILE socks_node_switch flag=${id} new_node=${new_node} @@ -170,6 +169,10 @@ start() { echolog " - Socks切换检测:端口[${socks_port}] 后备节点数量:${backup_node_num}" if [ "$backup_node_num" -eq 1 ]; then [ "$main_node" = "$backup_node" ] && return + elif [ "$backup_node_num" -gt 1 ]; then + [ "$restore_switch" != "1" ] && { + [ -z "$(echo $backup_node | grep -F "$main_node")" ] && backup_node="${backup_node} ${main_node}" + } fi else echolog " - Socks切换检测:端口[${socks_port}] 后备节点数量:0"