diff --git a/luci-app-fwlive/Makefile b/luci-app-fwlive/Makefile index 24148e685..10ada5a15 100644 --- a/luci-app-fwlive/Makefile +++ b/luci-app-fwlive/Makefile @@ -12,7 +12,7 @@ LUCI_DEPENDS:=+luci-base +logd +jsonfilter LUCI_PKGARCH:=all PKG_VERSION:=0.1.52 -PKG_RELEASE:=64 +PKG_RELEASE:=65 # Reproducible build: honor SOURCE_DATE_EPOCH from the build environment (set by docker-sdk.sh / CI). ifdef SOURCE_DATE_EPOCH diff --git a/luci-app-fwlive/README.md b/luci-app-fwlive/README.md index 428b76a52..8570bc5ec 100644 --- a/luci-app-fwlive/README.md +++ b/luci-app-fwlive/README.md @@ -43,7 +43,8 @@ No `luasrc/` — modern JS-only app. - Optional reverse DNS uses BusyBox `nslookup` (stock image; not a package depend) - No hard `firewall4` dependency - Menu depends on ACL only (no `fs` AND of `nft`+`iptables` — that hid the entry on stock fw3 and fw4) -- Runtime backend detection selects **fw4/nft** on supported **23.05+** images; log lines tagged **iptables** still classify. OpenWrt **21.02** / **22.03** are unsupported +- Support floor: OpenWrt **23.05+**. **21.02** / **22.03** are unsupported. +- Runtime backend reporting does not read the image release version. When the `nft` command is available, a successful ruleset dump reports `nft`; a failed dump leaves the backend `unknown`. Temporary-file setup failure is an exception: the helper still reports `nft` with an enrichment error. Log lines tagged **iptables** still classify. The rpcd plugin invokes its read helpers directly and does not require GNU `timeout`. The `log.read` ubus invocation uses ubus's native five-second reply diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile index 527665378..19baa8584 100644 --- a/luci-app-passwall/Makefile +++ b/luci-app-passwall/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall PKG_VERSION:=26.10.4 -PKG_RELEASE:=327 +PKG_RELEASE:=328 PKG_PO_VERSION:=$(PKG_VERSION) PKG_CONFIG_DEPENDS:= \ diff --git a/luci-app-passwall/root/usr/share/passwall/app.sh b/luci-app-passwall/root/usr/share/passwall/app.sh index 8cece5581..b51ab8baa 100755 --- a/luci-app-passwall/root/usr/share/passwall/app.sh +++ b/luci-app-passwall/root/usr/share/passwall/app.sh @@ -1286,12 +1286,16 @@ start_dns() { echolog " - 域名解析:使用SmartDNS,请确保配置正常。" china_ng_listen="127.0.0.1#${SMARTDNS_LISTEN_PORT}" - echolog " - SmartDNS(127.0.0.1#${SMARTDNS_LOCAL_PORT}) -> 国内分组(${group_domestic:-null}),SmartDNS(${china_ng_listen}) -> Dnsmasq" + if [ "${DNS_REDIRECT}" = "1" ]; then + echolog " - DNS 重定向 -> SmartDNS(${china_ng_listen}),直连 DNS -> 国内分组(${group_domestic:-null})" + else + echolog " - SmartDNS(127.0.0.1#${SMARTDNS_LOCAL_PORT}) -> 国内分组(${group_domestic:-null}),SmartDNS(${china_ng_listen}) -> Dnsmasq" + fi china_ng_listen="${china_ng_listen},::1#${SMARTDNS_LISTEN_PORT}" local subnet_ip=$(config_n_get @global[0] remote_dns_client_ip) lua $APP_PATH/helper_smartdns_add.lua -FLAG "default" -SMARTDNS_CONF "/tmp/etc/smartdns/$CONFIG.conf" \ - -LISTEN_PORT ${SMARTDNS_LISTEN_PORT} -LOCAL_PORT ${SMARTDNS_LOCAL_PORT} \ + -LISTEN_PORT ${SMARTDNS_LISTEN_PORT} -LOCAL_PORT ${SMARTDNS_LOCAL_PORT} -DNS_REDIRECT ${DNS_REDIRECT} \ -LOCAL_GROUP ${group_domestic:-null} -REMOTE_GROUP "passwall_proxy" -REMOTE_PROXY_SERVER ${GLOBAL_SOCKS_server} -USE_DEFAULT_DNS "${USE_DEFAULT_DNS:-direct}" \ -REMOTE_DNS ${smartdns_remote_dns} -DNS_MODE ${DNS_MODE:-socks} -TUN_DNS ${TUN_DNS} \ -USE_DIRECT_LIST "${USE_DIRECT_LIST}" -USE_PROXY_LIST "${USE_PROXY_LIST}" -USE_BLOCK_LIST "${USE_BLOCK_LIST}" -USE_GFW_LIST "${USE_GFW_LIST}" -CHN_LIST "${CHN_LIST}" \ @@ -1378,6 +1382,10 @@ start_dns() { uci -q add_list dhcp.@dnsmasq[0].addnmount=${GLOBAL_DNSMASQ_CONF_PATH} uci -q commit dhcp lua $APP_PATH/helper_dnsmasq.lua logic_restart -LOG 1 + elif [ "${DNS_SHUNT}" = "smartdns" ]; then + # SmartDNS reads DHCP leases itself; no forwarding dnsmasq instance is needed. + DNS_REDIRECT_PORT=${SMARTDNS_LISTEN_PORT} + set_cache_var "ACL_default_dns_port" "${DNS_REDIRECT_PORT}" else #Run a copy dnsmasq instance, DNS hijack for that need proxy devices. GLOBAL_DNSMASQ_PORT=$(get_new_port 11400) @@ -1497,7 +1505,7 @@ acl_app() { if [ -n "${GLOBAL_NODE}" ]; then set_cache_var "ACL_${sid}_node" "${GLOBAL_NODE}" set_cache_var "ACL_${sid}_redir_port" "${GLOBAL_redir_port}" - set_cache_var "ACL_${sid}_dns_port" "${GLOBAL_DNSMASQ_PORT}" + set_cache_var "ACL_${sid}_dns_port" "${DNS_REDIRECT_PORT:-${GLOBAL_DNSMASQ_PORT}}" set_cache_var "ACL_${sid}_default" "1" [ "$GLOBAL_SHUNT_NODE_FAKEDNS" = "1" ] && use_fakedns=1 else 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 09e1b71b6..4c6a8e50e 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 @@ -465,7 +465,9 @@ if IS_SHUNT_NODE and not only_global then SHUNT_LIST = SHUNT_LIST .. domain_list .. (_node_id:sub(1, 1) == "_" and "not-node" or "node") - log(string.format(" - Sing-Box/Xray分流规则(%s):%s", s.remarks, DNS_TRUST or "默认")) + if _node_id ~= "_direct" and _node_id ~= "_blackhole" then + log(string.format(" - Sing-Box/Xray分流规则(%s):%s", s.remarks, DNS_TRUST or "默认")) + end end 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 11168eca5..004b396a1 100644 --- a/luci-app-passwall/root/usr/share/passwall/helper_dnsmasq.lua +++ b/luci-app-passwall/root/usr/share/passwall/helper_dnsmasq.lua @@ -721,7 +721,9 @@ function add_rule(var) end end - log(string.format(" - Sing-Box/Xray分流规则(%s):%s", s.remarks, fwd_dns or "默认")) + if _node_id ~= "_direct" and _node_id ~= "_blackhole" then + log(string.format(" - Sing-Box/Xray分流规则(%s):%s", s.remarks, fwd_dns or "默认")) + end end end) elseif only_global == 1 and NO_PROXY_IPV6 == "1" then 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 39d8e3591..5e8641d8e 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 @@ -23,6 +23,7 @@ local NFTFLAG = var["-NFTFLAG"] local SUBNET = var["-SUBNET"] local LISTEN_PORT = var["-LISTEN_PORT"] local LOCAL_PORT = var["-LOCAL_PORT"] +local DNS_REDIRECT = var["-DNS_REDIRECT"] == "1" local sys = api.sys local fs = api.fs @@ -185,14 +186,26 @@ end local force_https_soa = api.uci_get_c("@global[0]", "force_https_soa") or 0 local proxy_server_name = "psw-proxy-server" +local listen_address = "[::]:" .. LISTEN_PORT .. (DNS_REDIRECT and "" or "@lo") +local local_domain = DNS_REDIRECT and api.uci_get("dhcp", "@dnsmasq[0]", "domain") config_lines = { - tonumber(LISTEN_PORT) ~= 0 and "bind [::]:" .. LISTEN_PORT .. "@lo" or "", + tonumber(LISTEN_PORT) ~= 0 and "bind " .. listen_address or "", + tonumber(LISTEN_PORT) ~= 0 and "bind-tcp " .. listen_address or "", (tonumber(LOCAL_PORT) ~= 0 and LOCAL_GROUP) and "bind [::]:" .. LOCAL_PORT .. "@lo -group " .. LOCAL_GROUP or "", + (tonumber(LOCAL_PORT) ~= 0 and LOCAL_GROUP) and "bind-tcp [::]:" .. LOCAL_PORT .. "@lo -group " .. LOCAL_GROUP or "", tonumber(force_https_soa) == 1 and "force-qtype-SOA 65" or "force-qtype-SOA -,65", "server 223.5.5.5 -bootstrap-dns", + -- Set the suffix before loading hosts/leases so initial records are expanded too. + (local_domain and local_domain ~= "") and "local-domain " .. local_domain or "", is_file_nonzero("/etc/hosts") and "hosts-file /etc/hosts" or "", DNS_MODE == "socks" and string.format("proxy-server socks5://%s -name %s", REMOTE_PROXY_SERVER, proxy_server_name) or "" } +if DNS_REDIRECT then + -- SmartDNS monitors the lease file and updates local records without a restart. + local lease_file = api.uci_get("dhcp", "@dnsmasq[0]", "leasefile") + if not lease_file or lease_file == "" then lease_file = "/tmp/dhcp.leases" end + table.insert(config_lines, string.format("dnsmasq-lease-file %q", lease_file)) +end if DNS_MODE == "socks" then for w in string.gmatch(REMOTE_DNS, '[^|]+') do local server_dns = api.trim(w) @@ -632,7 +645,9 @@ if IS_SHUNT_NODE and not only_global then SHUNT_LIST = SHUNT_LIST .. domain_list .. (_node_id:sub(1, 1) == "_" and "not-node" or "node") - log(string.format(" - Sing-Box/Xray分流规则(%s)使用分组:%s", s.remarks, REMOTE_GROUP or "默认")) + if _node_id ~= "_direct" and _node_id ~= "_blackhole" then + log(string.format(" - Sing-Box/Xray分流规则(%s)使用分组:%s", s.remarks, REMOTE_GROUP or "默认")) + end end end) @@ -770,4 +785,8 @@ end fs.symlink(TMP_CONF_FILE, SMARTDNS_CONF) sys.call(string.format('echo "conf-file %s" >> /etc/smartdns/custom.conf', string.gsub(SMARTDNS_CONF, "passwall", "passwall*"))) -log(" - SmartDNS已作为Dnsmasq上游,如果你自行配置了错误的DNS流程,将会导致域名(直连/代理)分流失效!!!") +if DNS_REDIRECT then + log(" - DNS 重定向直接使用 SmartDNS,DHCP 租约由 SmartDNS 自动加载。") +else + log(" - SmartDNS已作为Dnsmasq上游,如果你自行配置了错误的DNS流程,将会导致域名(直连/代理)分流失效!!!") +end