diff --git a/luci-app-passwall2/Makefile b/luci-app-passwall2/Makefile index 2ef577c36..8cf71db0d 100644 --- a/luci-app-passwall2/Makefile +++ b/luci-app-passwall2/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall2 -PKG_VERSION:=25.1.1 +PKG_VERSION:=25.1.8 PKG_RELEASE:=1 PKG_CONFIG_DEPENDS:= \ diff --git a/luci-app-passwall2/luasrc/controller/passwall2.lua b/luci-app-passwall2/luasrc/controller/passwall2.lua index 7cd9e8252..efcb3bd56 100644 --- a/luci-app-passwall2/luasrc/controller/passwall2.lua +++ b/luci-app-passwall2/luasrc/controller/passwall2.lua @@ -98,16 +98,14 @@ function reset_config() end function show_menu() - uci:delete(appname, "@global[0]", "hide_from_luci") - api.uci_save(uci, appname, true) + api.sh_uci_del(appname, "@global[0]", "hide_from_luci", true) luci.sys.call("rm -rf /tmp/luci-*") luci.sys.call("/etc/init.d/rpcd restart >/dev/null") luci.http.redirect(api.url()) end function hide_menu() - uci:set(appname, "@global[0]", "hide_from_luci","1") - api.uci_save(uci, appname, true) + api.sh_uci_set(appname, "@global[0]", "hide_from_luci", "1", true) luci.sys.call("rm -rf /tmp/luci-*") luci.sys.call("/etc/init.d/rpcd restart >/dev/null") luci.http.redirect(luci.dispatcher.build_url("admin", "status", "overview")) @@ -294,8 +292,7 @@ function set_node() local config = luci.http.formvalue("config") local section = luci.http.formvalue("section") uci:set(appname, type, config, section) - api.uci_save(uci, appname, true) - luci.sys.call("/etc/init.d/passwall2 restart > /dev/null 2>&1 &") + api.uci_save(uci, appname, true, true) luci.http.redirect(api.url("log")) end diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua index a8937fe72..bc333c3cd 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua @@ -337,10 +337,15 @@ o = s:taboption("DNS", Flag, "dns_redirect", translate("DNS Redirect"), translat o.default = "1" o.rmempty = false -o = s:taboption("DNS", Button, "clear_ipset", translate("Clear IPSet"), translate("Try this feature if the rule modification does not take effect.")) +if (m:get("@global_forwarding[0]", "use_nft") or "0") == "1" then + o = s:taboption("DNS", Button, "clear_ipset", translate("Clear NFTSET"), translate("Try this feature if the rule modification does not take effect.")) +else + o = s:taboption("DNS", Button, "clear_ipset", translate("Clear IPSET"), translate("Try this feature if the rule modification does not take effect.")) +end o.inputstyle = "remove" function o.write(e, e) - luci.sys.call('[ -n "$(nft list sets 2>/dev/null | grep \"passwall2_\")" ] && sh /usr/share/passwall2/nftables.sh flush_nftset_reload || sh /usr/share/passwall2/iptables.sh flush_ipset_reload > /dev/null 2>&1 &') + m:set("@global[0]", "flush_set", "1") + api.uci_save(m.uci, appname, true, true) luci.http.redirect(api.url("log")) end diff --git a/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua b/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua index 824bec4ae..f3d132db8 100644 --- a/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua +++ b/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua @@ -1301,7 +1301,7 @@ function gen_config(var) experimental.cache_file = { enabled = true, store_fakeip = true, - path = "/tmp/singbox_passwall2_" .. flag .. ".db" + path = CACHE_PATH .. "/singbox_" .. flag .. ".db" } end diff --git a/luci-app-passwall2/root/usr/share/passwall2/iptables.sh b/luci-app-passwall2/root/usr/share/passwall2/iptables.sh index c6e5aa458..497783400 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/iptables.sh +++ b/luci-app-passwall2/root/usr/share/passwall2/iptables.sh @@ -968,24 +968,16 @@ del_firewall_rule() { ip -6 rule del fwmark 1 table 100 2>/dev/null ip -6 route del local ::/0 dev lo table 100 2>/dev/null - $DIR/app.sh echolog "删除iptables防火墙规则完成。" + $DIR/app.sh echolog "删除 iptables 规则完成。" } flush_ipset() { - $DIR/app.sh echolog "清空 IPSET。" + $DIR/app.sh echolog "清空 IPSet。" for _name in $(ipset list | grep "Name: " | grep "passwall2_" | awk '{print $2}'); do destroy_ipset ${_name} done } -flush_ipset_reload() { - del_firewall_rule - flush_ipset - rm -rf /tmp/singbox_passwall2_* - rm -f /tmp/etc/passwall2_tmp/geoip-*.json - /etc/init.d/passwall2 reload -} - flush_include() { echo '#!/bin/sh' >$FWI } @@ -1076,6 +1068,13 @@ start() { stop() { del_firewall_rule + [ $(config_t_get global flush_set "0") = "1" ] && { + uci -q delete ${CONFIG}.@global[0].flush_set + uci -q commit ${CONFIG} + flush_ipset + rm -rf /tmp/etc/passwall2_tmp/singbox* + rm -f /tmp/etc/passwall2_tmp/geoip-*.json + } flush_include } @@ -1091,12 +1090,6 @@ insert_rule_before) insert_rule_after) insert_rule_after "$@" ;; -flush_ipset) - flush_ipset - ;; -flush_ipset_reload) - flush_ipset_reload - ;; get_ipt_bin) get_ipt_bin ;; diff --git a/luci-app-passwall2/root/usr/share/passwall2/nftables.sh b/luci-app-passwall2/root/usr/share/passwall2/nftables.sh index 64305bf56..784eb5e9f 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/nftables.sh +++ b/luci-app-passwall2/root/usr/share/passwall2/nftables.sh @@ -1027,11 +1027,11 @@ del_firewall_rule() { destroy_nftset $NFTSET_LAN6 destroy_nftset $NFTSET_VPS6 - $DIR/app.sh echolog "删除nftables防火墙规则完成。" + $DIR/app.sh echolog "删除 nftables 规则完成。" } flush_nftset() { - $DIR/app.sh echolog "清空 NFTSET。" + $DIR/app.sh echolog "清空 NFTSet。" for _name in $(nft -a list sets | grep -E "passwall2" | awk -F 'set ' '{print $2}' | awk '{print $1}'); do destroy_nftset ${_name} done @@ -1042,14 +1042,6 @@ flush_table() { nft delete table $NFTABLE_NAME } -flush_nftset_reload() { - del_firewall_rule - flush_table - rm -rf /tmp/singbox_passwall2_* - rm -f /tmp/etc/passwall2_tmp/geoip-*.json - /etc/init.d/passwall2 reload -} - flush_include() { echo '#!/bin/sh' >$FWI } @@ -1101,6 +1093,14 @@ start() { stop() { del_firewall_rule + [ $(config_t_get global flush_set "0") = "1" ] && { + uci -q delete ${CONFIG}.@global[0].flush_set + uci -q commit ${CONFIG} + #flush_table + flush_nftset + rm -rf /tmp/etc/passwall2_tmp/singbox* + rm -f /tmp/etc/passwall2_tmp/geoip-*.json + } flush_include } @@ -1116,12 +1116,6 @@ insert_rule_before) insert_rule_after) insert_rule_after "$@" ;; -flush_nftset) - flush_nftset - ;; -flush_nftset_reload) - flush_nftset_reload - ;; get_wan_ip) get_wan_ip ;; diff --git a/luci-app-passwall2/root/usr/share/passwall2/rule_update.lua b/luci-app-passwall2/root/usr/share/passwall2/rule_update.lua index f23283c47..f0c5b2af9 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/rule_update.lua +++ b/luci-app-passwall2/root/usr/share/passwall2/rule_update.lua @@ -93,6 +93,9 @@ local function fetch_geoip() end end end + if json.message then + log(json.message) + end end, function(e) end) @@ -144,6 +147,9 @@ local function fetch_geosite() end end end + if json.message then + log(json.message) + end end, function(e) end) @@ -196,10 +202,7 @@ if reboot == 1 then end log("重启服务,应用新的规则。") - if use_nft == "1" then - sys.call("sh /usr/share/" .. name .. "/nftables.sh flush_nftset_reload > /dev/null 2>&1 &") - else - sys.call("sh /usr/share/" .. name .. "/iptables.sh flush_ipset_reload > /dev/null 2>&1 &") - end + uci:set(name, "@global[0]", "flush_set", "1") + api.uci_save(uci, name, true, true) end log("规则更新完毕...")