From b920bb930038e8db0676b5fbee4193cb8e703588 Mon Sep 17 00:00:00 2001 From: action Date: Sun, 16 Aug 2026 20:28:05 +0800 Subject: [PATCH] update 2026-08-16 20:28:05 --- dae/Makefile | 2 +- .../model/cbi/passwall/client/acl_config.lua | 8 ++++- .../model/cbi/passwall/client/global.lua | 10 +++++- .../passwall/client/node_subscribe_config.lua | 4 +-- .../luasrc/passwall/util_sing-box.lua | 32 +++++++++++++------ .../root/usr/share/passwall/app.sh | 16 +++++++--- 6 files changed, 53 insertions(+), 19 deletions(-) diff --git a/dae/Makefile b/dae/Makefile index e80abfb9..a70f8757 100644 --- a/dae/Makefile +++ b/dae/Makefile @@ -10,7 +10,7 @@ PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=7666cccc681ad21b66156f95a8db627bcbf2b244 +PKG_SOURCE_VERSION:=cda30d78b2dc01af0062df8fa40f5f88b83bf2c9 PKG_SOURCE_URL:=https://github.com/olicesx/dae.git PKG_MIRROR_HASH:=skip 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 86991c34..5540c8d4 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 @@ -519,7 +519,7 @@ o.validate = function(self, value, t) local _dns_mode = s.fields["dns_mode"]:formvalue(t) local _tcp_node = s.fields["tcp_node"]:formvalue(t) if _dns_mode and _tcp_node then - if (m:get(_tcp_node, "type") or ""):lower() ~= _dns_mode and not _tcp_node:find("Socks_") then + if (m:get(_tcp_node, "type") or ""):lower() ~= _dns_mode and not _tcp_node:find("socks_") then return nil, translatef("TCP node must be '%s' type to use FakeDNS.", _dns_mode) end end @@ -527,6 +527,11 @@ o.validate = function(self, value, t) return value end +o = s:option(Value, "remote_rewrite_ttl", translate("Remote DNS") .. " TTL") +o.datatype = "min(1)" +o.default = "30" +o:depends({dns_mode = "sing-box"}) + o = s:option(ListValue, "chinadns_ng_default_tag", translate("Default DNS")) o.default = "none" o:value("gfw", translate("Remote DNS")) @@ -588,6 +593,7 @@ for k, v in pairs(nodes_table) do s.fields["singbox_dns_mode"]:depends({ _tcp_node_bool = "1", tcp_node = v.id }) s.fields["_node_sel_shunt"]:depends({ tcp_node = v.id }) + s.fields["remote_rewrite_ttl"]:depends({ _tcp_node_bool = "1", tcp_node = v.id }) end else tcp:value(v.id, v["remark"]) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua index f6be0833..10ccfc2e 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua @@ -480,7 +480,7 @@ o.validate = function(self, value, t) end local _tcp_node = s.fields["tcp_node"]:formvalue(t) if _dns_mode and _tcp_node then - if (m:get(_tcp_node, "type") or ""):lower() ~= _dns_mode and not _tcp_node:find("Socks_") then + if (m:get(_tcp_node, "type") or ""):lower() ~= _dns_mode and not _tcp_node:find("socks_") then return nil, translatef("TCP node must be '%s' type to use FakeDNS.", _dns_mode) end end @@ -488,6 +488,13 @@ o.validate = function(self, value, t) return value end +o = s:taboption("DNS", Value, "remote_rewrite_ttl", translate("Remote DNS") .. " TTL") +o.datatype = "min(1)" +o.default = "30" +o:depends({dns_mode = "sing-box", dns_shunt = "dnsmasq"}) +o:depends({dns_mode = "sing-box", dns_shunt = "chinadns-ng"}) +o:depends({smartdns_dns_mode = "sing-box", dns_shunt = "smartdns"}) + o = s:taboption("DNS", ListValue, "chinadns_ng_default_tag", translate("Default DNS")) o.default = "none" o:value("gfw", translate("Remote DNS")) @@ -794,6 +801,7 @@ for k, v in pairs(nodes_table) do s.fields["xray_dns_mode"]:depends({ tcp_node = v.id }) else s.fields["singbox_dns_mode"]:depends({ tcp_node = v.id }) + s.fields["remote_rewrite_ttl"]:depends({ tcp_node = v.id }) end end else 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 c5351a9c..a4ce2a19 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 @@ -92,7 +92,7 @@ o.write = function(self, section, value) if old ~= value then m:foreach("nodes", function(e) if e["group"] and e["group"]:lower() == old:lower() then - self:set(e[".name"], "group", value) + self.map:set(e[".name"], "group", value) end if e["protocol"] and (e["protocol"] == "_balancing" or e["protocol"] == "_urltest") and e["node_group"] then local gs = "" @@ -104,7 +104,7 @@ o.write = function(self, section, value) end end gs = api.trim(gs) - self:set(e[".name"], "node_group", gs) + self.map:set(e[".name"], "node_group", gs) end end) end diff --git a/luci-app-passwall/luasrc/passwall/util_sing-box.lua b/luci-app-passwall/luasrc/passwall/util_sing-box.lua index 34e310c0..f8f43a9e 100644 --- a/luci-app-passwall/luasrc/passwall/util_sing-box.lua +++ b/luci-app-passwall/luasrc/passwall/util_sing-box.lua @@ -1087,6 +1087,7 @@ function gen_config(var) local remote_dns_client_ip = var["remote_dns_client_ip"] local remote_dns_query_strategy = var["remote_dns_query_strategy"] local remote_dns_fake = var["remote_dns_fake"] + local remote_rewrite_ttl = var["remote_rewrite_ttl"] or "30" local dns_cache = var["dns_cache"] local dns_socks_address = var["dns_socks_address"] local dns_socks_port = var["dns_socks_port"] @@ -2015,7 +2016,7 @@ function gen_config(var) end if value.outboundTag ~= "block" and value.outboundTag ~= "direct" then dns_rule.server = "remote" - dns_rule.rewrite_ttl = 30 + dns_rule.rewrite_ttl = tonumber(remote_rewrite_ttl) if true then local block_rule if remote_strategy == "ipv4_only" then @@ -2063,29 +2064,42 @@ function gen_config(var) end end if default_dns_flag == "remote" then + local block_rule local dns_rule_query_type = { "A", "AAAA" } if remote_strategy == "ipv4_only" then + block_rule = { + query_type = { "AAAA" }, + action = "predefined", + rcode = "NOERROR" + } dns_rule_query_type = { "A" } elseif remote_strategy == "ipv6_only" then + block_rule = { + query_type = { "A" }, + action = "predefined", + rcode = "NOERROR" + } dns_rule_query_type = { "AAAA" } end + if block_rule then + table.insert(dns.rules, block_rule) + end if remote_dns_fake then -- When default is not direct and enable fakedns, default DNS use FakeDNS. local fakedns_dns_rule = { query_type = dns_rule_query_type, server = fakedns_tag, disable_cache = true, - rewrite_ttl = 30 + rewrite_ttl = tonumber(remote_rewrite_ttl) } table.insert(dns.rules, fakedns_dns_rule) - else - local remote_dns_rule = { - query_type = dns_rule_query_type, - server = "remote", - disable_cache = true, - } - table.insert(dns.rules, remote_dns_rule) end + local remote_dns_rule = { + server = "remote", + disable_cache = true, + rewrite_ttl = tonumber(remote_rewrite_ttl) + } + table.insert(dns.rules, remote_dns_rule) end local dns_in_inbound = { type = "direct", diff --git a/luci-app-passwall/root/usr/share/passwall/app.sh b/luci-app-passwall/root/usr/share/passwall/app.sh index c328df10..660b7e4b 100755 --- a/luci-app-passwall/root/usr/share/passwall/app.sh +++ b/luci-app-passwall/root/usr/share/passwall/app.sh @@ -98,7 +98,7 @@ run_ipt2socks() { run_singbox() { local flag type node tcp_redir_port tcp_proxy_way udp_redir_port socks_address socks_port socks_username socks_password http_address http_port http_username http_password - local dns_listen_port direct_dns_query_strategy direct_dns_port direct_dns_udp_server direct_dns_tcp_server remote_dns_protocol remote_dns_udp_server remote_dns_tcp_server remote_dns_doh remote_dns_client_ip remote_fakedns remote_dns_query_strategy dns_cache dns_socks_address dns_socks_port + local dns_listen_port direct_dns_query_strategy direct_dns_port direct_dns_udp_server direct_dns_tcp_server remote_dns_protocol remote_dns_udp_server remote_dns_tcp_server remote_dns_doh remote_dns_client_ip remote_fakedns remote_dns_query_strategy remote_rewrite_ttl dns_cache dns_socks_address dns_socks_port local loglevel log_file config_file server_host server_port no_run use_proxy_list use_gfw_list chn_list eval_set_val "$@" [ -z "$type" ] && { @@ -179,6 +179,7 @@ run_singbox() { [ -n "$remote_dns_client_ip" ] && json_add_string "remote_dns_client_ip" "${remote_dns_client_ip}" [ "$remote_fakedns" = "1" ] && json_add_string "remote_dns_fake" "1" + [ -n "$remote_rewrite_ttl" ] && json_add_string "remote_rewrite_ttl" "${remote_rewrite_ttl}" [ -n "$no_run" ] && json_add_string "no_run" "1" local _json_arg="$(json_dump)" lua $UTIL_SINGBOX gen_config "${_json_arg}" > $config_file @@ -763,6 +764,7 @@ run_redir() { resolve_dns_log="${resolve_dns_log} + FakeDNS" USE_FAKEDNS=1 } + _args="${_args} remote_rewrite_ttl=$(config_t_get global remote_rewrite_ttl)" NEXT_DNS_LISTEN_PORT=$(expr $NEXT_DNS_LISTEN_PORT + 1) } _args="${_args} use_proxy_list=$USE_PROXY_LIST use_gfw_list=$USE_GFW_LIST chn_list=$CHN_LIST" @@ -1274,6 +1276,7 @@ start_dns() { _args="${_args} remote_fakedns=1" USE_FAKEDNS=1 } + _args="${_args} remote_rewrite_ttl=$(config_t_get global remote_rewrite_ttl)" local _remote_dns_client_ip=$(config_t_get global remote_dns_client_ip) [ -n "${_remote_dns_client_ip}" ] && _args="${_args} remote_dns_client_ip=${_remote_dns_client_ip}" TCP_PROXY_DNS=1 @@ -1621,9 +1624,9 @@ acl_app() { dns_mode=$type [ "$type" = "xray" ] && [ "$v2ray_dns_mode" = "http3" ] && v2ray_dns_mode="tcp" } - dns_cache_key="${dns_mode}_${remote_dns}_${v2ray_dns_mode:-none}_${remote_dns_client_ip:-0}_${remote_fakedns:-0}" + dns_cache_key="${dns_mode}_${remote_dns}_${v2ray_dns_mode:-none}_${remote_dns_client_ip:-0}_${remote_fakedns:-0}_${remote_rewrite_ttl:-30}" ([ "$v2ray_dns_mode" = "doh" ] || [ "$v2ray_dns_mode" = "http3" ]) && { - dns_cache_key="${dns_mode}_${remote_dns_doh:-https://1.1.1.1/dns-query}_${v2ray_dns_mode:-doh}_${remote_dns_client_ip:-0}_${remote_fakedns:-0}" + dns_cache_key="${dns_mode}_${remote_dns_doh:-https://1.1.1.1/dns-query}_${v2ray_dns_mode:-doh}_${remote_dns_client_ip:-0}_${remote_fakedns:-0}_${remote_rewrite_ttl:-30}" } if [ "$remote_fakedns" = "1" ] || ([ "$protocol" = "_shunt" ] && [ "$(config_n_get $tcp_node fakedns)" = "1" ]); then @@ -1750,7 +1753,10 @@ acl_app() { _extra_param="${_extra_param} udp_redir_port=$redir_port" } config_file="$TMP_PATH/$config_file" - [ "${type}" = "sing-box" ] && type="singbox" + [ "${type}" = "sing-box" ] && { + type="singbox" + _extra_param="${_extra_param} remote_rewrite_ttl=${remote_rewrite_ttl:-30}" + } _extra_param="${_extra_param} use_proxy_list=$use_proxy_list use_gfw_list=$use_gfw_list chn_list=$chn_list" run_${type} flag=$tcp_node node=$tcp_node tcp_redir_port=$redir_port ${_extra_param} config_file=$config_file log_file=$log_file loglevel=$loglevel else @@ -1843,7 +1849,7 @@ acl_app() { } unset enabled sid remarks sources interface tcp_no_redir_ports udp_no_redir_ports use_global_config tcp_node udp_node use_direct_list use_proxy_list use_block_list use_gfw_list chn_list tcp_proxy_mode udp_proxy_mode filter_proxy_ipv6 dns_mode remote_dns v2ray_dns_mode remote_dns_doh remote_dns_client_ip unset _ip _mac _iprange _ipset _ip_or_mac source_list tcp_port udp_port config_file _extra_param dns_cache_key log loglevel - unset _china_ng_listen _chinadns_local_dns _direct_dns_mode chinadns_ng_default_tag dnsmasq_filter_proxy_ipv6 remote_fakedns force_https_soa use_fakedns + unset _china_ng_listen _chinadns_local_dns _direct_dns_mode chinadns_ng_default_tag dnsmasq_filter_proxy_ipv6 remote_fakedns force_https_soa use_fakedns remote_rewrite_ttl done unset socks_port redir_port dns_port dnsmasq_port chinadns_port [ -n "${has_enabled}" ] || {