From b350686c9eee210d7b6bd807108eda100cb0b5fb Mon Sep 17 00:00:00 2001 From: action Date: Tue, 19 May 2026 22:49:48 +0800 Subject: [PATCH] update 2026-05-19 22:49:48 --- luci-app-cpu-perf/Makefile | 4 +- luci-app-cpu-perf/README.md | 24 ++--- luci-app-cpu-perf/root/etc/init.d/cpu-perf | 6 +- .../model/cbi/passwall/client/acl_config.lua | 99 +------------------ .../passwall/client/node_subscribe_config.lua | 9 ++ .../model/cbi/passwall/client/type/ray.lua | 6 +- .../cbi/passwall/client/type/sing-box.lua | 6 +- luci-app-passwall/luasrc/passwall/api.lua | 80 +++++++++++++++ .../share/passwall/helper_chinadns_add.lua | 40 ++++---- .../usr/share/passwall/helper_dnsmasq.lua | 50 +++++----- .../share/passwall/helper_smartdns_add.lua | 36 +++---- .../root/usr/share/passwall/iptables.sh | 54 +++++----- .../root/usr/share/passwall/nftables.sh | 54 +++++----- .../root/usr/share/passwall/rule_update.lua | 6 +- .../root/usr/share/passwall/subscribe.lua | 7 +- 15 files changed, 245 insertions(+), 236 deletions(-) diff --git a/luci-app-cpu-perf/Makefile b/luci-app-cpu-perf/Makefile index 96449ad6..dcc75507 100644 --- a/luci-app-cpu-perf/Makefile +++ b/luci-app-cpu-perf/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2025 gSpot (https://github.com/gSpotx2f/luci-app-cpu-perf) +# Copyright (C) 2026 gSpot (https://github.com/gSpotx2f/luci-app-cpu-perf) # # This is free software, licensed under the MIT License. # @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-cpu-perf -PKG_VERSION:=0.6.1 +PKG_VERSION:=0.6.2 PKG_RELEASE:=1 LUCI_TITLE:=CPU performance information and management for LuCI LUCI_DEPENDS:=+ucode +ucode-mod-fs diff --git a/luci-app-cpu-perf/README.md b/luci-app-cpu-perf/README.md index dee308c1..359a195e 100644 --- a/luci-app-cpu-perf/README.md +++ b/luci-app-cpu-perf/README.md @@ -9,31 +9,31 @@ OpenWrt >= 22.03. **OpenWrt >= 25.12:** - wget --no-check-certificate -O /tmp/luci-app-cpu-perf-0.6.1-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/luci-app-cpu-perf-0.6.1-r1.apk - apk --allow-untrusted add /tmp/luci-app-cpu-perf-0.6.1-r1.apk - rm /tmp/luci-app-cpu-perf-0.6.1-r1.apk + wget --no-check-certificate -O /tmp/luci-app-cpu-perf-0.6.2-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/luci-app-cpu-perf-0.6.2-r1.apk + apk --allow-untrusted add /tmp/luci-app-cpu-perf-0.6.2-r1.apk + rm /tmp/luci-app-cpu-perf-0.6.2-r1.apk service rpcd restart service cpu-perf start i18n-ru: - wget --no-check-certificate -O /tmp/luci-i18n-cpu-perf-ru-0.6.1-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/luci-i18n-cpu-perf-ru-0.6.1-r1.apk - apk --allow-untrusted add /tmp/luci-i18n-cpu-perf-ru-0.6.1-r1.apk - rm /tmp/luci-i18n-cpu-perf-ru-0.6.1-r1.apk + wget --no-check-certificate -O /tmp/luci-i18n-cpu-perf-ru-0.6.2-r1.apk https://github.com/gSpotx2f/packages-openwrt/raw/master/25.12/luci-i18n-cpu-perf-ru-0.6.2-r1.apk + apk --allow-untrusted add /tmp/luci-i18n-cpu-perf-ru-0.6.2-r1.apk + rm /tmp/luci-i18n-cpu-perf-ru-0.6.2-r1.apk **OpenWrt <= 24.10:** - wget --no-check-certificate -O /tmp/luci-app-cpu-perf_0.6.1-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/luci-app-cpu-perf_0.6.1-r1_all.ipk - opkg install /tmp/luci-app-cpu-perf_0.6.1-r1_all.ipk - rm /tmp/luci-app-cpu-perf_0.6.1-r1_all.ipk + wget --no-check-certificate -O /tmp/luci-app-cpu-perf_0.6.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/luci-app-cpu-perf_0.6.2-r1_all.ipk + opkg install /tmp/luci-app-cpu-perf_0.6.2-r1_all.ipk + rm /tmp/luci-app-cpu-perf_0.6.2-r1_all.ipk service rpcd restart service cpu-perf start i18n-ru: - wget --no-check-certificate -O /tmp/luci-i18n-cpu-perf-ru_0.6.1-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/luci-i18n-cpu-perf-ru_0.6.1-r1_all.ipk - opkg install /tmp/luci-i18n-cpu-perf-ru_0.6.1-r1_all.ipk - rm /tmp/luci-i18n-cpu-perf-ru_0.6.1-r1_all.ipk + wget --no-check-certificate -O /tmp/luci-i18n-cpu-perf-ru_0.6.2-r1_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/24.10/luci-i18n-cpu-perf-ru_0.6.2-r1_all.ipk + opkg install /tmp/luci-i18n-cpu-perf-ru_0.6.2-r1_all.ipk + rm /tmp/luci-i18n-cpu-perf-ru_0.6.2-r1_all.ipk ## Screenshots: diff --git a/luci-app-cpu-perf/root/etc/init.d/cpu-perf b/luci-app-cpu-perf/root/etc/init.d/cpu-perf index 003c3783..fd553dea 100755 --- a/luci-app-cpu-perf/root/etc/init.d/cpu-perf +++ b/luci-app-cpu-perf/root/etc/init.d/cpu-perf @@ -34,8 +34,8 @@ EAS_DEF=1 config_load $APP_NAME get_cpu_freq_policies() { + [ ! -d "$SYSFS_CPU_FREQ_DIR" ] && return echo $(ls "$SYSFS_CPU_FREQ_DIR" | grep "^policy[0-9]*$") - } reset_cpu_freq_policy_config() { @@ -67,7 +67,7 @@ set_cpu_freq_policy() { local scaling_min_freq scaling_max_freq scaling_governor local policy_dir="${SYSFS_CPU_FREQ_DIR}/${policy}" - [ ! -d $policy_dir ] && return + [ ! -d "$policy_dir" ] && return local scaling_min_freq_file="${policy_dir}/scaling_min_freq" local scaling_max_freq_file="${policy_dir}/scaling_max_freq" @@ -92,7 +92,7 @@ reset_cpu_freq_policy() { local policy="$1" local policy_dir="${SYSFS_CPU_FREQ_DIR}/${policy}" - [ ! -d $policy_dir ] && return + [ ! -d "$policy_dir" ] && return local min_freq_file="${policy_dir}/cpuinfo_min_freq" local max_freq_file="${policy_dir}/cpuinfo_max_freq" diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/acl_config.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/acl_config.lua index 7fdb88b1..d908e37d 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/acl_config.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/acl_config.lua @@ -83,103 +83,10 @@ o.rmempty = false o = s:option(Value, "interface", translate("Source Interface")) o:value("", translate("All")) --- Populate with actual kernel network devices instead of UCI interface names, --- because the backend (nftables iifname / iptables -i) matches kernel device names. -do - local nfs = require "nixio.fs" - local _cursor = require("luci.model.uci").cursor() - local _sysnet = "/sys/class/net/" - - -- Map UCI interface names to their device names and vice versa - local _iface_to_dev = {} - local _dev_to_ifaces = {} - local _iface_proto = {} - _cursor:foreach("network", "interface", function(sec) - local name = sec[".name"] - if name ~= "loopback" then - _iface_proto[name] = sec.proto - if sec.device then - _iface_to_dev[name] = sec.device - _dev_to_ifaces[sec.device] = _dev_to_ifaces[sec.device] or {} - table.insert(_dev_to_ifaces[sec.device], name) - end - end - end) - - -- Classify device type using sysfs attributes - local function classify_sysfs(dev) - if nfs.stat(_sysnet .. dev .. "/bridge", "type") == "dir" then - return translate("Bridge") - elseif nfs.stat(_sysnet .. dev .. "/wireless", "type") == "dir" then - return translate("Wireless Adapter") - elseif dev:match("^tun") or dev:match("^tap") or dev:match("^wg") or dev:match("^ppp") then - return translate("Tunnel Interface") - else - return translate("Ethernet Adapter") - end - end - - -- Classify offline UCI interfaces by config hints - local function classify_uci(dev_name, proto) - if dev_name and dev_name:match("^br%-") then - return translate("Bridge") - elseif proto == "wireguard" or proto == "pppoe" or proto == "pptp" or proto == "l2tp" then - return translate("Tunnel Interface") - else - return translate("Interface") - end - end - - local _seen = {} - local _devices = {} - - -- Active kernel devices from /sys/class/net/. - -- Skip bridge member ports (/master) and DSA master devices (/dsa) because - -- nftables iifname matches the parent bridge for routed traffic, not - -- individual member ports. Also skip internal virtual devices. - local _iter = nfs.dir(_sysnet) - if _iter then - for dev in _iter do - if dev ~= "lo" - and not dev:match("^veth") - and not dev:match("^ifb") - and not dev:match("^gre") - and not dev:match("^sit") - and not dev:match("^ip6tnl") - and not dev:match("^erspan") - and not nfs.stat(_sysnet .. dev .. "/master", "type") - and not nfs.stat(_sysnet .. dev .. "/dsa", "type") - then - local dtype = classify_sysfs(dev) - local label = dtype .. ': "' .. dev .. '"' - if _dev_to_ifaces[dev] then - label = label .. " (" .. table.concat(_dev_to_ifaces[dev], ", ") .. ")" - end - _devices[#_devices + 1] = { name = dev, label = label, sort = dtype .. ":" .. dev } - _seen[dev] = true - end - end - end - - -- UCI interfaces whose device does not currently exist (down tunnels, VPNs, etc.). - -- Stored by UCI name since the kernel device is not available yet. - -- Dedup by device: if two interfaces share a device, only one is shown. - for iface, dev in pairs(_iface_to_dev) do - if not _seen[dev] then - local dtype = classify_uci(dev, _iface_proto[iface]) - local label = dtype .. ': "' .. iface .. '"' - -- Sort offline entries after active devices - _devices[#_devices + 1] = { name = iface, label = label, sort = "zzz:" .. iface } - _seen[dev] = true - end - end - - table.sort(_devices, function(a, b) return a.sort < b.sort end) - for _, d in ipairs(_devices) do - o:value(d.name, d.label) - end +local iface = api.get_network_devices() +for _, d in ipairs(iface) do + o:value(d.name, d.label) end - o.validate = function(self, value, section) if value == "" or value:match("^[a-zA-Z0-9][a-zA-Z0-9%.%_%-]*$") then return value diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/node_subscribe_config.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/node_subscribe_config.lua index 4be4bc59..90858054 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/node_subscribe_config.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/node_subscribe_config.lua @@ -288,6 +288,7 @@ o = s:option(ListValue, "chain_proxy", translate("Chain Proxy")) o:value("", translate("Close(Not use)")) o:value("1", translate("Preproxy Node")) o:value("2", translate("Landing Node")) +o:value("3", translate("Outbound Interface")) local descrStr = "Chained proxy works only with Xray or Sing-box nodes.
" descrStr = descrStr .. "You can only use manual or imported nodes as chained nodes." @@ -305,6 +306,14 @@ o2.description = descrStr o2.template = appname .. "/cbi/nodes_listvalue" o2.group = {} +o3 = s:option(Value, "outbound_iface", translate("Outbound Interface")) +o3:depends({ ["chain_proxy"] = "3" }) +o3:value("", translate("All")) +local iface = api.get_network_devices() +for _, d in ipairs(iface) do + o3:value(d.name, d.label) +end + for k, v in pairs(nodes_table) do if (v.type == "Xray" or v.type == "sing-box") and (not v.chain_proxy or v.chain_proxy == "") and v.add_mode ~= "2" then o1:value(v.id, v.remark) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua index 169ca8a3..363866c1 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua @@ -816,8 +816,12 @@ if not load_shunt_options then o1.group = {} o3 = s:option(Value, _n("outbound_iface"), translate("Outbound Interface")) - o3.default = "eth1" o3:depends({ [_n("chain_proxy")] = "3" }) + o3:value("", translate("All")) + local iface = api.get_network_devices() + for _, d in ipairs(iface) do + o3:value(d.name, d.label) + end o2 = s:option(ListValue, _n("to_node"), translate("Landing Node"), translate("Only support a layer of proxy.")) o2:depends({ [_n("chain_proxy")] = "2" }) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua index 0b1cbf07..ada8094f 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/sing-box.lua @@ -834,8 +834,12 @@ if not load_shunt_options then o1.group = {} o3 = s:option(Value, _n("outbound_iface"), translate("Outbound Interface")) - o3.default = "eth1" o3:depends({ [_n("chain_proxy")] = "3" }) + o3:value("", translate("All")) + local iface = api.get_network_devices() + for _, d in ipairs(iface) do + o3:value(d.name, d.label) + end o2 = s:option(ListValue, _n("to_node"), translate("Landing Node"), translate("Only support a layer of proxy.")) o2:depends({ [_n("chain_proxy")] = "2", [_n("hysteria2_realms")] = false }) diff --git a/luci-app-passwall/luasrc/passwall/api.lua b/luci-app-passwall/luasrc/passwall/api.lua index a4e1cb6b..ebde80e4 100644 --- a/luci-app-passwall/luasrc/passwall/api.lua +++ b/luci-app-passwall/luasrc/passwall/api.lua @@ -1626,3 +1626,83 @@ function parse_realm_uri(uri) end return realm end + +function get_network_devices() + local _sysnet = "/sys/class/net/" + -- Map UCI interface names to their device names and vice versa + local _iface_to_dev = {} + local _dev_to_ifaces = {} + local _iface_proto = {} + uci:foreach("network", "interface", function(sec) + local name = sec[".name"] + if name ~= "loopback" then + _iface_proto[name] = sec.proto + if sec.device then + _iface_to_dev[name] = sec.device + _dev_to_ifaces[sec.device] = _dev_to_ifaces[sec.device] or {} + table.insert(_dev_to_ifaces[sec.device], name) + end + end + end) + -- Classify device type using sysfs attributes + local function classify_sysfs(dev) + if fs.stat(_sysnet .. dev .. "/bridge", "type") == "dir" then + return i18n.translate("Bridge") + elseif fs.stat(_sysnet .. dev .. "/wireless", "type") == "dir" then + return i18n.translate("Wireless Adapter") + elseif dev:match("^tun") or dev:match("^tap") or dev:match("^wg") or dev:match("^ppp") then + return i18n.translate("Tunnel Interface") + else + return i18n.translate("Ethernet Adapter") + end + end + -- Classify offline UCI interfaces by config hints + local function classify_uci(dev_name, proto) + if dev_name and dev_name:match("^br%-") then + return i18n.translate("Bridge") + elseif proto == "wireguard" or proto == "pppoe" or proto == "pptp" or proto == "l2tp" then + return i18n.translate("Tunnel Interface") + else + return i18n.translate("Interface") + end + end + + local _seen = {} + local _devices = {} + -- Active kernel devices from /sys/class/net/ + -- Skip bridge member ports (/master) and DSA master devices (/dsa) + local _iter = fs.dir(_sysnet) + if _iter then + for dev in _iter do + if dev ~= "lo" + and not dev:match("^veth") + and not dev:match("^ifb") + and not dev:match("^gre") + and not dev:match("^sit") + and not dev:match("^ip6tnl") + and not dev:match("^erspan") + and not fs.stat(_sysnet .. dev .. "/master", "type") + and not fs.stat(_sysnet .. dev .. "/dsa", "type") + then + local dtype = classify_sysfs(dev) + local label = dtype .. ': "' .. dev .. '"' + if _dev_to_ifaces[dev] then + label = label .. " (" .. table.concat(_dev_to_ifaces[dev], ", ") .. ")" + end + _devices[#_devices + 1] = { name = dev, label = label, sort = dtype .. ":" .. dev } + _seen[dev] = true + end + end + end + -- UCI interfaces whose device does not currently exist + for iface, dev in pairs(_iface_to_dev) do + if not _seen[dev] then + local dtype = classify_uci(dev, _iface_proto[iface]) + local label = dtype .. ': "' .. iface .. '"' + _devices[#_devices + 1] = { name = iface, label = label, sort = "zzz:" .. iface } + _seen[dev] = true + end + end + table.sort(_devices, function(a, b) return a.sort < b.sort end) + return _devices +end diff --git a/luci-app-passwall/root/usr/share/passwall/helper_chinadns_add.lua b/luci-app-passwall/root/usr/share/passwall/helper_chinadns_add.lua index 46f056bd..209fe258 100644 --- a/luci-app-passwall/root/usr/share/passwall/helper_chinadns_add.lua +++ b/luci-app-passwall/root/usr/share/passwall/helper_chinadns_add.lua @@ -194,8 +194,8 @@ if not is_file_nonzero(file_vpslist) then end if is_file_nonzero(file_vpslist) then local sets = { - setflag .. "passwall_vps", - setflag .. "passwall_vps6" + setflag .. "psw_vps", + setflag .. "psw_vps6" } tmp_lines = { "group vpslist", @@ -240,8 +240,8 @@ if USE_DIRECT_LIST == "1" and not fs.access(file_direct_host) then end if USE_DIRECT_LIST == "1" and is_file_nonzero(file_direct_host) then local sets = { - setflag .. "passwall_white", - setflag .. "passwall_white6" + setflag .. "psw_white", + setflag .. "psw_white6" } tmp_lines = { "group directlist", @@ -286,13 +286,13 @@ if USE_PROXY_LIST == "1" and not fs.access(file_proxy_host) then end if USE_PROXY_LIST == "1" and is_file_nonzero(file_proxy_host) then local sets = { - setflag .. "passwall_black", - setflag .. "passwall_black6" + setflag .. "psw_black", + setflag .. "psw_black6" } if FLAG ~= "default" then sets = { - setflag .. "passwall_" .. FLAG .. "_black", - setflag .. "passwall_" .. FLAG .. "_black6" + setflag .. "psw_" .. FLAG .. "_black", + setflag .. "psw_" .. FLAG .. "_black6" } end tmp_lines = { @@ -310,13 +310,13 @@ end --GFW列表 if GFWLIST == "1" and is_file_nonzero(RULES_PATH .. "/gfwlist") then local sets = { - setflag .. "passwall_gfw", - setflag .. "passwall_gfw6" + setflag .. "psw_gfw", + setflag .. "psw_gfw6" } if FLAG ~= "default" then sets = { - setflag .. "passwall_" .. FLAG .. "_gfw", - setflag .. "passwall_" .. FLAG .. "_gfw6" + setflag .. "psw_" .. FLAG .. "_gfw", + setflag .. "psw_" .. FLAG .. "_gfw6" } end tmp_lines = { @@ -333,8 +333,8 @@ if CHNLIST ~= "0" and is_file_nonzero(RULES_PATH .. "/chnlist") then if CHNLIST == "direct" then tmp_lines = { "chnlist-file " .. RULES_PATH .. "/chnlist", - "ipset-name4 " .. setflag .. "passwall_chn", - "ipset-name6 " .. setflag .. "passwall_chn6", + "ipset-name4 " .. setflag .. "psw_chn", + "ipset-name6 " .. setflag .. "psw_chn6", "add-tagchn-ip", "chnlist-first" } @@ -345,8 +345,8 @@ if CHNLIST ~= "0" and is_file_nonzero(RULES_PATH .. "/chnlist") then --回中国模式 if CHNLIST == "proxy" then local sets = { - setflag .. "passwall_chn", - setflag .. "passwall_chn6" + setflag .. "psw_chn", + setflag .. "psw_chn6" } tmp_lines = { "group chn_proxy", @@ -445,13 +445,13 @@ if IS_SHUNT_NODE then end local sets = { - setflag .. "passwall_shunt", - setflag .. "passwall_shunt6" + setflag .. "psw_shunt", + setflag .. "psw_shunt6" } if FLAG ~= "default" then sets = { - setflag .. "passwall_" .. FLAG .. "_shunt", - setflag .. "passwall_" .. FLAG .. "_shunt6" + setflag .. "psw_" .. FLAG .. "_shunt", + setflag .. "psw_" .. FLAG .. "_shunt6" } end diff --git a/luci-app-passwall/root/usr/share/passwall/helper_dnsmasq.lua b/luci-app-passwall/root/usr/share/passwall/helper_dnsmasq.lua index 7b21e165..2b318cfc 100644 --- a/luci-app-passwall/root/usr/share/passwall/helper_dnsmasq.lua +++ b/luci-app-passwall/root/usr/share/passwall/helper_dnsmasq.lua @@ -372,8 +372,8 @@ function add_rule(var) fwd_dns = nil else local sets = { - setflag_4 .. "passwall_vps", - setflag_6 .. "passwall_vps6" + setflag_4 .. "psw_vps", + setflag_6 .. "psw_vps6" } local function process_address(address) address = (address or ""):lower() @@ -406,8 +406,8 @@ function add_rule(var) end if fwd_dns then local sets = { - setflag_4 .. "passwall_white", - setflag_6 .. "passwall_white6" + setflag_4 .. "psw_white", + setflag_6 .. "psw_white6" } --始终用国内DNS解析直连(白名单)列表 for line in io.lines("/usr/share/passwall/rules/direct_host") do @@ -431,11 +431,11 @@ function add_rule(var) fwd_dns = nil end if fwd_dns then - local set_name = "passwall_black" - local set6_name = "passwall_black6" + local set_name = "psw_black" + local set6_name = "psw_black6" if FLAG ~= "default" then - set_name = "passwall_" .. FLAG .. "_black" - set6_name = "passwall_" .. FLAG .. "_black6" + set_name = "psw_" .. FLAG .. "_black" + set6_name = "psw_" .. FLAG .. "_black6" end local sets = { setflag_4 .. set_name @@ -471,11 +471,11 @@ function add_rule(var) fwd_dns = nil end if fwd_dns then - local set_name = "passwall_gfw" - local set6_name = "passwall_gfw6" + local set_name = "psw_gfw" + local set6_name = "psw_gfw6" if FLAG ~= "default" then - set_name = "passwall_" .. FLAG .. "_gfw" - set6_name = "passwall_" .. FLAG .. "_gfw6" + set_name = "psw_" .. FLAG .. "_gfw" + set6_name = "psw_" .. FLAG .. "_gfw6" end local sets = { setflag_4 .. set_name @@ -519,13 +519,13 @@ function add_rule(var) end if fwd_dns then local sets = { - setflag_4 .. "passwall_chn", - setflag_6 .. "passwall_chn6" + setflag_4 .. "psw_chn", + setflag_6 .. "psw_chn6" } if CHN_LIST == "proxy" then if NO_PROXY_IPV6 == "1" then sets = { - setflag_4 .. "passwall_chn" + setflag_4 .. "psw_chn" } end if REMOTE_FAKEDNS == "1" then @@ -569,24 +569,24 @@ function add_rule(var) if _node_id == "_direct" then fwd_dns = LOCAL_DNS if USE_DIRECT_LIST == "1" then - table.insert(sets, setflag_4 .. "passwall_white") - table.insert(sets, setflag_6 .. "passwall_white6") + table.insert(sets, setflag_4 .. "psw_white") + table.insert(sets, setflag_6 .. "psw_white6") else - local set_name = "passwall_shunt" - local set6_name = "passwall_shunt6" + local set_name = "psw_shunt" + local set6_name = "psw_shunt6" if FLAG ~= "default" then - set_name = "passwall_" .. FLAG .. "_shunt" - set6_name = "passwall_" .. FLAG .. "_shunt6" + set_name = "psw_" .. FLAG .. "_shunt" + set6_name = "psw_" .. FLAG .. "_shunt6" end table.insert(sets, setflag_4 .. set_name) table.insert(sets, setflag_6 .. set6_name) end else - local set_name = "passwall_shunt" - local set6_name = "passwall_shunt6" + local set_name = "psw_shunt" + local set6_name = "psw_shunt6" if FLAG ~= "default" then - set_name = "passwall_" .. FLAG .. "_shunt" - set6_name = "passwall_" .. FLAG .. "_shunt6" + set_name = "psw_" .. FLAG .. "_shunt" + set6_name = "psw_" .. FLAG .. "_shunt6" end fwd_dns = TUN_DNS table.insert(sets, setflag_4 .. set_name) diff --git a/luci-app-passwall/root/usr/share/passwall/helper_smartdns_add.lua b/luci-app-passwall/root/usr/share/passwall/helper_smartdns_add.lua index 7e1d13bc..ae7b46da 100644 --- a/luci-app-passwall/root/usr/share/passwall/helper_smartdns_add.lua +++ b/luci-app-passwall/root/usr/share/passwall/helper_smartdns_add.lua @@ -358,8 +358,8 @@ if is_file_nonzero(file_vpslist) then string.format("domain-set -name %s -file %s", domain_set_name, file_vpslist) } local sets = { - "#4:" .. setflag .. "passwall_vps", - "#6:" .. setflag .. "passwall_vps6" + "#4:" .. setflag .. "psw_vps", + "#6:" .. setflag .. "psw_vps6" } local domain_rules_str = string.format('domain-rules /domain-set:%s/ %s', domain_set_name, LOCAL_GROUP and "-nameserver " .. LOCAL_GROUP or "") domain_rules_str = domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",") @@ -406,8 +406,8 @@ if USE_DIRECT_LIST == "1" and is_file_nonzero(file_direct_host) then string.format("domain-set -name %s -file %s", domain_set_name, file_direct_host) } local sets = { - "#4:" .. setflag .. "passwall_white", - "#6:" .. setflag .. "passwall_white6" + "#4:" .. setflag .. "psw_white", + "#6:" .. setflag .. "psw_white6" } local domain_rules_str = string.format('domain-rules /domain-set:%s/ %s', domain_set_name, LOCAL_GROUP and "-nameserver " .. LOCAL_GROUP or "") domain_rules_str = domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",") @@ -457,14 +457,14 @@ if USE_PROXY_LIST == "1" and is_file_nonzero(file_proxy_host) then domain_rules_str = domain_rules_str .. " -speed-check-mode none" domain_rules_str = domain_rules_str .. " -no-serve-expired" local sets = { - "#4:" .. setflag .. "passwall_black" + "#4:" .. setflag .. "psw_black" } if NO_PROXY_IPV6 == "1" then domain_rules_str = domain_rules_str .. " -address #6" domain_rules_str = REMOTE_FAKEDNS ~= "1" and (domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",")) or domain_rules_str else domain_rules_str = domain_rules_str .. " -address -6" - table.insert(sets, "#6:" .. setflag .. "passwall_black6") + table.insert(sets, "#6:" .. setflag .. "psw_black6") domain_rules_str = REMOTE_FAKEDNS ~= "1" and (domain_rules_str .. " -d no " .. set_type .. " " .. table.concat(sets, ",")) or domain_rules_str end table.insert(tmp_lines, domain_rules_str) @@ -482,14 +482,14 @@ if USE_GFW_LIST == "1" and is_file_nonzero(RULES_PATH .. "/gfwlist") then domain_rules_str = domain_rules_str .. " -speed-check-mode none" domain_rules_str = domain_rules_str .. " -no-serve-expired" local sets = { - "#4:" .. setflag .. "passwall_gfw" + "#4:" .. setflag .. "psw_gfw" } if NO_PROXY_IPV6 == "1" then domain_rules_str = domain_rules_str .. " -address #6" domain_rules_str = REMOTE_FAKEDNS ~= "1" and (domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",")) or domain_rules_str else domain_rules_str = domain_rules_str .. " -address -6" - table.insert(sets, "#6:" .. setflag .. "passwall_gfw6") + table.insert(sets, "#6:" .. setflag .. "psw_gfw6") domain_rules_str = REMOTE_FAKEDNS ~= "1" and (domain_rules_str .. " -d no " .. set_type .. " " .. table.concat(sets, ",")) or domain_rules_str end table.insert(tmp_lines, domain_rules_str) @@ -506,8 +506,8 @@ if CHN_LIST ~= "0" and is_file_nonzero(RULES_PATH .. "/chnlist") then if CHN_LIST == "direct" then local sets = { - "#4:" .. setflag .. "passwall_chn", - "#6:" .. setflag .. "passwall_chn6" + "#4:" .. setflag .. "psw_chn", + "#6:" .. setflag .. "psw_chn6" } local domain_rules_str = string.format('domain-rules /domain-set:%s/ %s', domain_set_name, LOCAL_GROUP and "-nameserver " .. LOCAL_GROUP or "") domain_rules_str = domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",") @@ -523,14 +523,14 @@ if CHN_LIST ~= "0" and is_file_nonzero(RULES_PATH .. "/chnlist") then domain_rules_str = domain_rules_str .. " -speed-check-mode none" domain_rules_str = domain_rules_str .. " -no-serve-expired" local sets = { - "#4:" .. setflag .. "passwall_chn" + "#4:" .. setflag .. "psw_chn" } if NO_PROXY_IPV6 == "1" then domain_rules_str = domain_rules_str .. " -address #6" domain_rules_str = REMOTE_FAKEDNS ~= "1" and (domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",")) or domain_rules_str else domain_rules_str = domain_rules_str .. " -address -6" - table.insert(sets, "#6:" .. setflag .. "passwall_chn6") + table.insert(sets, "#6:" .. setflag .. "psw_chn6") domain_rules_str = REMOTE_FAKEDNS ~= "1" and (domain_rules_str .. " -d no " .. set_type .. " " .. table.concat(sets, ",")) or domain_rules_str end table.insert(tmp_lines, domain_rules_str) @@ -631,14 +631,14 @@ if IS_SHUNT_NODE then local domain_rules_str = string.format('domain-rules /domain-set:%s/ %s', domain_set_name, LOCAL_GROUP and "-nameserver " .. LOCAL_GROUP or "") if USE_DIRECT_LIST == "1" then local sets = { - "#4:" .. setflag .. "passwall_white", - "#6:" .. setflag .. "passwall_white6" + "#4:" .. setflag .. "psw_white", + "#6:" .. setflag .. "psw_white6" } domain_rules_str = domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",") else local sets = { - "#4:" .. setflag .. "passwall_shunt", - "#6:" .. setflag .. "passwall_shunt6" + "#4:" .. setflag .. "psw_shunt", + "#6:" .. setflag .. "psw_shunt6" } domain_rules_str = domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",") end @@ -656,7 +656,7 @@ if IS_SHUNT_NODE then domain_rules_str = domain_rules_str .. " -speed-check-mode none" domain_rules_str = domain_rules_str .. " -no-serve-expired" local sets = { - "#4:" .. setflag .. "passwall_shunt" + "#4:" .. setflag .. "psw_shunt" } if NO_PROXY_IPV6 == "1" then domain_rules_str = domain_rules_str .. " -address #6" @@ -665,7 +665,7 @@ if IS_SHUNT_NODE then or (domain_rules_str .. " " .. set_type .. " " .. table.concat(sets, ",")) else domain_rules_str = domain_rules_str .. " -address -6" - table.insert(sets, "#6:" .. setflag .. "passwall_shunt6") + table.insert(sets, "#6:" .. setflag .. "psw_shunt6") domain_rules_str = (not only_global and REMOTE_FAKEDNS == "1") and domain_rules_str or (domain_rules_str .. " -d no " .. set_type .. " " .. table.concat(sets, ",")) diff --git a/luci-app-passwall/root/usr/share/passwall/iptables.sh b/luci-app-passwall/root/usr/share/passwall/iptables.sh index 6229dbf0..ede11735 100755 --- a/luci-app-passwall/root/usr/share/passwall/iptables.sh +++ b/luci-app-passwall/root/usr/share/passwall/iptables.sh @@ -3,27 +3,27 @@ DIR="$(cd "$(dirname "$0")" && pwd)" MY_PATH=$DIR/iptables.sh UTILS_PATH=$DIR/utils.sh -IPSET_LOCAL="passwall_local" -IPSET_WAN="passwall_wan" -IPSET_LAN="passwall_lan" -IPSET_VPS="passwall_vps" -IPSET_SHUNT="passwall_shunt" -IPSET_GFW="passwall_gfw" -IPSET_CHN="passwall_chn" -IPSET_BLACK="passwall_black" -IPSET_WHITE="passwall_white" -IPSET_BLOCK="passwall_block" +IPSET_LOCAL="psw_local" +IPSET_WAN="psw_wan" +IPSET_LAN="psw_lan" +IPSET_VPS="psw_vps" +IPSET_SHUNT="psw_shunt" +IPSET_GFW="psw_gfw" +IPSET_CHN="psw_chn" +IPSET_BLACK="psw_black" +IPSET_WHITE="psw_white" +IPSET_BLOCK="psw_block" -IPSET_LOCAL6="passwall_local6" -IPSET_WAN6="passwall_wan6" -IPSET_LAN6="passwall_lan6" -IPSET_VPS6="passwall_vps6" -IPSET_SHUNT6="passwall_shunt6" -IPSET_GFW6="passwall_gfw6" -IPSET_CHN6="passwall_chn6" -IPSET_BLACK6="passwall_black6" -IPSET_WHITE6="passwall_white6" -IPSET_BLOCK6="passwall_block6" +IPSET_LOCAL6="psw_local6" +IPSET_WAN6="psw_wan6" +IPSET_LAN6="psw_lan6" +IPSET_VPS6="psw_vps6" +IPSET_SHUNT6="psw_shunt6" +IPSET_GFW6="psw_gfw6" +IPSET_CHN6="psw_chn6" +IPSET_BLACK6="psw_black6" +IPSET_WHITE6="psw_white6" +IPSET_BLOCK6="psw_block6" USE_SHUNT_TCP=0 USE_SHUNT_UDP=0 @@ -365,24 +365,24 @@ load_acl() { if ([ -n "$tcp_port" ] && [ -n "${tcp_proxy_mode}" ]) || ([ -n "$udp_port" ] && [ -n "${udp_proxy_mode}" ]); then [ "${use_proxy_list}" = "1" ] && { [ "${use_global_config}" = "0" ] && { - black_set_name="passwall_${sid}_black" - black6_set_name="passwall_${sid}_black6" + black_set_name="psw_${sid}_black" + black6_set_name="psw_${sid}_black6" ipset -! create $black_set_name nethash maxelem 1048576 timeout 172800 ipset -! create $black6_set_name nethash family inet6 maxelem 1048576 timeout 172800 } } [ "${use_gfw_list}" = "1" ] && { [ "${use_global_config}" = "0" ] && { - gfw_set_name="passwall_${sid}_gfw" - gfw6_set_name="passwall_${sid}_gfw6" + gfw_set_name="psw_${sid}_gfw" + gfw6_set_name="psw_${sid}_gfw6" ipset -! create $gfw_set_name nethash maxelem 1048576 timeout 172800 ipset -! create $gfw6_set_name nethash family inet6 maxelem 1048576 timeout 172800 } } [ "${use_shunt_tcp}" = "1" -o "${use_shunt_udp}" = "1" ] && { [ "${use_global_config}" = "0" ] && { - shunt_set_name="passwall_${sid}_shunt" - shunt6_set_name="passwall_${sid}_shunt6" + shunt_set_name="psw_${sid}_shunt" + shunt6_set_name="psw_${sid}_shunt6" ipset -! create $shunt_set_name nethash maxelem 1048576 timeout 172800 ipset -! create $shunt6_set_name nethash family inet6 maxelem 1048576 timeout 172800 } @@ -1400,7 +1400,7 @@ del_firewall_rule() { flush_ipset() { echolog "清空 IPSet。" - for _name in $(ipset list | grep "Name: " | grep "passwall_" | awk '{print $2}'); do + for _name in $(ipset list | grep "Name: " | grep "psw_" | awk '{print $2}'); do destroy_ipset ${_name} done } diff --git a/luci-app-passwall/root/usr/share/passwall/nftables.sh b/luci-app-passwall/root/usr/share/passwall/nftables.sh index e683d1f7..5147ea2f 100755 --- a/luci-app-passwall/root/usr/share/passwall/nftables.sh +++ b/luci-app-passwall/root/usr/share/passwall/nftables.sh @@ -4,27 +4,27 @@ DIR="$(cd "$(dirname "$0")" && pwd)" MY_PATH=$DIR/nftables.sh UTILS_PATH=$DIR/utils.sh NFTABLE_NAME="inet passwall" -NFTSET_LOCAL="passwall_local" -NFTSET_WAN="passwall_wan" -NFTSET_LAN="passwall_lan" -NFTSET_VPS="passwall_vps" -NFTSET_SHUNT="passwall_shunt" -NFTSET_GFW="passwall_gfw" -NFTSET_CHN="passwall_chn" -NFTSET_BLACK="passwall_black" -NFTSET_WHITE="passwall_white" -NFTSET_BLOCK="passwall_block" +NFTSET_LOCAL="psw_local" +NFTSET_WAN="psw_wan" +NFTSET_LAN="psw_lan" +NFTSET_VPS="psw_vps" +NFTSET_SHUNT="psw_shunt" +NFTSET_GFW="psw_gfw" +NFTSET_CHN="psw_chn" +NFTSET_BLACK="psw_black" +NFTSET_WHITE="psw_white" +NFTSET_BLOCK="psw_block" -NFTSET_LOCAL6="passwall_local6" -NFTSET_WAN6="passwall_wan6" -NFTSET_LAN6="passwall_lan6" -NFTSET_VPS6="passwall_vps6" -NFTSET_SHUNT6="passwall_shunt6" -NFTSET_GFW6="passwall_gfw6" -NFTSET_CHN6="passwall_chn6" -NFTSET_BLACK6="passwall_black6" -NFTSET_WHITE6="passwall_white6" -NFTSET_BLOCK6="passwall_block6" +NFTSET_LOCAL6="psw_local6" +NFTSET_WAN6="psw_wan6" +NFTSET_LAN6="psw_lan6" +NFTSET_VPS6="psw_vps6" +NFTSET_SHUNT6="psw_shunt6" +NFTSET_GFW6="psw_gfw6" +NFTSET_CHN6="psw_chn6" +NFTSET_BLACK6="psw_black6" +NFTSET_WHITE6="psw_white6" +NFTSET_BLOCK6="psw_block6" USE_SHUNT_TCP=0 USE_SHUNT_UDP=0 @@ -395,24 +395,24 @@ load_acl() { if ([ -n "$tcp_port" ] && [ -n "${tcp_proxy_mode}" ]) || ([ -n "$udp_port" ] && [ -n "${udp_proxy_mode}" ]); then [ "${use_proxy_list}" = "1" ] && { [ "${use_global_config}" = "0" ] && { - black_set_name="passwall_${sid}_black" - black6_set_name="passwall_${sid}_black6" + black_set_name="psw_${sid}_black" + black6_set_name="psw_${sid}_black6" gen_nftset $black_set_name ipv4_addr "2d" 0 gen_nftset $black6_set_name ipv6_addr "2d" 0 } } [ "${use_gfw_list}" = "1" ] && { [ "${use_global_config}" = "0" ] && { - gfw_set_name="passwall_${sid}_gfw" - gfw6_set_name="passwall_${sid}_gfw6" + gfw_set_name="psw_${sid}_gfw" + gfw6_set_name="psw_${sid}_gfw6" gen_nftset $gfw_set_name ipv4_addr "2d" 0 gen_nftset $gfw6_set_name ipv6_addr "2d" 0 } } [ "${use_shunt_tcp}" = "1" -o "${use_shunt_udp}" = "1" ] && { [ "${use_global_config}" = "0" ] && { - shunt_set_name="passwall_${sid}_shunt" - shunt6_set_name="passwall_${sid}_shunt6" + shunt_set_name="psw_${sid}_shunt" + shunt6_set_name="psw_${sid}_shunt6" gen_nftset $shunt_set_name ipv4_addr "2d" 0 gen_nftset $shunt6_set_name ipv6_addr "2d" 0 } @@ -1462,7 +1462,7 @@ del_firewall_rule() { flush_nftset() { echolog "清空 NFTSet。" - for _name in $(nft -a list sets | grep -E "passwall_" | awk -F 'set ' '{print $2}' | awk '{print $1}'); do + for _name in $(nft -a list sets | grep -E "psw_" | awk -F 'set ' '{print $2}' | awk '{print $1}'); do destroy_nftset ${_name} done } diff --git a/luci-app-passwall/root/usr/share/passwall/rule_update.lua b/luci-app-passwall/root/usr/share/passwall/rule_update.lua index 14b39067..d022b9ec 100755 --- a/luci-app-passwall/root/usr/share/passwall/rule_update.lua +++ b/luci-app-passwall/root/usr/share/passwall/rule_update.lua @@ -506,9 +506,9 @@ local function fetch_rule(rule_name, rule_type, url, exclude_domain, max_retries if old_md5 ~= new_md5 then if api.is_finded("fw4") and (rule_type == "ip4" or rule_type == "ip6") then local nft_file = file_tmp .. ".nft" - local set_name = "passwall_" .. rule_name - if rule_name == "chnroute" then set_name = "passwall_chn" - elseif rule_name == "chnroute6" then set_name = "passwall_chn6" end + local set_name = "psw_" .. rule_name + if rule_name == "chnroute" then set_name = "psw_chn" + elseif rule_name == "chnroute6" then set_name = "psw_chn6" end local addr_type = (rule_type == "ip4") and "ipv4_addr" or "ipv6_addr" gen_cache(set_name, addr_type, file_tmp, nft_file) diff --git a/luci-app-passwall/root/usr/share/passwall/subscribe.lua b/luci-app-passwall/root/usr/share/passwall/subscribe.lua index 52f0b0d2..c3a7cf5f 100755 --- a/luci-app-passwall/root/usr/share/passwall/subscribe.lua +++ b/luci-app-passwall/root/usr/share/passwall/subscribe.lua @@ -1883,7 +1883,7 @@ local function update_node(manual) local list = v["list"] local sub_cfg = v["sub_cfg"] local domain_resolver, domain_resolver_dns, domain_resolver_dns_https, domain_strategy - local preproxy_node_group, to_node_group, chain_node_type = "", "", "" + local preproxy_node_group, to_node_group, outbound_iface_group, chain_node_type = "", "", "", "" -- Subscription Group Chain Agent local function valid_chain_node(node) if not node then return "" end @@ -1904,6 +1904,8 @@ local function update_node(manual) domain_strategy = (sub_cfg.domain_strategy and map[sub_cfg.domain_strategy]) and sub_cfg.domain_strategy or nil preproxy_node_group = (sub_cfg.chain_proxy == "1") and valid_chain_node(sub_cfg.preproxy_node) or "" to_node_group = (sub_cfg.chain_proxy == "2") and valid_chain_node(sub_cfg.to_node) or "" + outbound_iface_group = (sub_cfg.chain_proxy == "3") and sub_cfg.outbound_iface or "" + chain_node_type = (outbound_iface_group ~= "") and "iface" or chain_node_type end for _, vv in ipairs(list) do local cfgid = uci:section(appname, "nodes", api.gen_short_uuid()) @@ -1941,6 +1943,9 @@ local function update_node(manual) elseif to_node_group ~= "" then uci:set(appname, cfgid, "chain_proxy", "2") uci:set(appname, cfgid, "to_node", to_node_group) + elseif outbound_iface_group ~= "" then + uci:set(appname, cfgid, "chain_proxy", "3") + uci:set(appname, cfgid, "outbound_iface", outbound_iface_group) end end end