From 587815b3442c0efccf0c42fefc28d67ddeb46330 Mon Sep 17 00:00:00 2001 From: action Date: Fri, 28 Aug 2026 02:44:45 +0800 Subject: [PATCH] update 2026-08-28 02:44:45 --- .../luasrc/controller/passwall.lua | 2 + .../model/cbi/passwall/client/acl_config.lua | 1 + .../model/cbi/passwall/client/global.lua | 4 +- .../luasrc/passwall/util_sing-box.lua | 7 -- .../luasrc/passwall/util_xray.lua | 8 ++ .../root/usr/share/passwall/iptables.sh | 12 +- .../root/usr/share/passwall/nftables.sh | 19 ++-- .../root/usr/share/passwall/rule_update.lua | 24 +++- .../model/cbi/passwall2/client/acl_config.lua | 2 +- .../model/cbi/passwall2/client/global.lua | 2 +- luci-app-passwall2/luasrc/passwall2/api.lua | 26 ++++- .../luasrc/passwall2/util_xray.lua | 8 +- .../root/usr/share/passwall2/app.sh | 104 ++++++++++-------- .../root/usr/share/passwall2/app_acl.lua | 7 +- .../usr/share/passwall2/helper_dnsmasq.lua | 2 +- .../root/usr/share/passwall2/iptables.sh | 2 +- .../root/usr/share/passwall2/nftables.sh | 2 +- .../root/usr/share/passwall2/utils.sh | 22 ---- luci-app-syncthing/Makefile | 22 ---- luci-app-syncthing/README.md | 2 - .../luasrc/controller/syncthing.lua | 17 --- .../luasrc/model/cbi/syncthing.lua | 48 -------- .../view/syncthing/syncthing_status.htm | 27 ----- .../root/etc/uci-defaults/luci-syncthing | 12 -- .../share/rpcd/acl.d/luci-app-syncthing.json | 11 -- 25 files changed, 143 insertions(+), 250 deletions(-) delete mode 100644 luci-app-syncthing/Makefile delete mode 100644 luci-app-syncthing/README.md delete mode 100644 luci-app-syncthing/luasrc/controller/syncthing.lua delete mode 100644 luci-app-syncthing/luasrc/model/cbi/syncthing.lua delete mode 100644 luci-app-syncthing/luasrc/view/syncthing/syncthing_status.htm delete mode 100644 luci-app-syncthing/root/etc/uci-defaults/luci-syncthing delete mode 100644 luci-app-syncthing/root/usr/share/rpcd/acl.d/luci-app-syncthing.json diff --git a/luci-app-passwall/luasrc/controller/passwall.lua b/luci-app-passwall/luasrc/controller/passwall.lua index 3d787cb8..a9fd8a78 100644 --- a/luci-app-passwall/luasrc/controller/passwall.lua +++ b/luci-app-passwall/luasrc/controller/passwall.lua @@ -752,6 +752,8 @@ function rollback_rules() if geo2rule == "1" and rules ~= "" then luci.sys.call("lua /usr/share/passwall/rule_update.lua log '" .. rules .. "' rollback > /dev/null") end + uci_set("@global[0]", "flush_set", "1") + uci_save(true) http_write_json_ok() end 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 dbacc653..ade58c03 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 @@ -402,6 +402,7 @@ end ---- DNS Forward o = s:option(Value, "remote_dns", translate("Remote DNS")) +o.datatype = "or(ipaddr,ipaddrport(1))" o.default = "1.1.1.1" o:value("1.1.1.1", "1.1.1.1 (CloudFlare)") o:value("1.1.1.2", "1.1.1.2 (CloudFlare-Security)") 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 160bf390..cb057592 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua @@ -213,7 +213,7 @@ o:depends({dns_shunt = "dnsmasq"}) o:depends({dns_shunt = "chinadns-ng"}) o = s:taboption("DNS", Value, "direct_dns", translate("Direct DNS")) -o.datatype = "or(ipaddr,ipaddrport)" +o.datatype = "or(ipaddr,ipaddrport(1))" o.default = "223.5.5.5" o:value("223.5.5.5") o:value("223.6.6.6") @@ -389,7 +389,7 @@ o:depends({dns_mode = "dns2socks"}) ---- DNS Forward o = s:taboption("DNS", Value, "remote_dns", translate("Remote DNS")) -o.datatype = "or(ipaddr,ipaddrport)" +o.datatype = "or(ipaddr,ipaddrport(1))" o.default = "1.1.1.1" o:value("1.1.1.1", "1.1.1.1 (CloudFlare)") o:value("1.1.1.2", "1.1.1.2 (CloudFlare-Security)") diff --git a/luci-app-passwall/luasrc/passwall/util_sing-box.lua b/luci-app-passwall/luasrc/passwall/util_sing-box.lua index e3ab33d5..c8780b26 100644 --- a/luci-app-passwall/luasrc/passwall/util_sing-box.lua +++ b/luci-app-passwall/luasrc/passwall/util_sing-box.lua @@ -69,13 +69,6 @@ local function convert_geofile() end local function convert(file_path, prefix, tags) if next(tags) and fs.access(file_path) then - local md5_file = GEO_VAR.TO_SRS_PATH .. prefix .. ".dat.md5" - local new_md5 = sys.exec("md5sum " .. file_path .. " 2>/dev/null | awk '{print $1}'"):gsub("\n", "") - local old_md5 = sys.exec("[ -f " .. md5_file .. " ] && head -n 1 " .. md5_file .. " | tr -d ' \t\n' || echo ''") - if new_md5 ~= "" and new_md5 ~= old_md5 then - sys.call("printf '%s' " .. new_md5 .. " > " .. md5_file) - sys.call("rm -rf " .. GEO_VAR.TO_SRS_PATH .. prefix .. "-*.srs" ) - end for k in pairs(tags) do geo_convert_srs({["geo_path"] = file_path, ["prefix"] = prefix, ["rule_name"] = k}) end diff --git a/luci-app-passwall/luasrc/passwall/util_xray.lua b/luci-app-passwall/luasrc/passwall/util_xray.lua index 5b988ab3..6a0c4bbb 100644 --- a/luci-app-passwall/luasrc/passwall/util_xray.lua +++ b/luci-app-passwall/luasrc/passwall/util_xray.lua @@ -1664,8 +1664,12 @@ function gen_config(var) _direct_dns.port = port _direct_dns.address = direct_dns_udp_server elseif direct_dns_tcp_server then + if api.is_ipv6(direct_dns_tcp_server) then + direct_dns_tcp_server = api.get_ipv6_full(direct_dns_tcp_server) + end local port = tonumber(direct_dns_port) or 53 _direct_dns.address = "tcp://" .. direct_dns_tcp_server .. ":" .. port + _direct_dns.port = port end if COMMON.default_outbound_tag == "direct" then @@ -1697,7 +1701,11 @@ function gen_config(var) _remote_dns.port = tonumber(remote_dns_udp_port) or 53 elseif remote_dns_tcp_server then + if api.is_ipv6(remote_dns_tcp_server) then + remote_dns_tcp_server = api.get_ipv6_full(remote_dns_tcp_server) + end _remote_dns.address = "tcp://" .. remote_dns_tcp_server .. ":" .. tonumber(remote_dns_tcp_port) or 53 + _remote_dns.port = tonumber(remote_dns_tcp_port) or 53 elseif remote_dns_doh then local _a = api.parseDoH(remote_dns_doh) diff --git a/luci-app-passwall/root/usr/share/passwall/iptables.sh b/luci-app-passwall/root/usr/share/passwall/iptables.sh index 6e9d0e3b..a98c6b60 100755 --- a/luci-app-passwall/root/usr/share/passwall/iptables.sh +++ b/luci-app-passwall/root/usr/share/passwall/iptables.sh @@ -44,6 +44,7 @@ FAKE_IP="198.18.0.0/15" FAKE_IP_6="fc00::/18" USE_GEOVIEW=0 +EXCLUDE_VPSIP="^(0\.0\.0\.0|127\.0\.0\.1|1\.1\.1\.1|1\.1\.1\.2|8\.8\.8\.8|8\.8\.4\.4|9\.9\.9\.9)$" factor() { if [ -z "$1" ] || [ -z "$2" ]; then @@ -746,15 +747,14 @@ load_acl() { } filter_haproxy() { - for item in ${haproxy_items}; do - local ip=$(get_host_ip ipv4 $(echo $item | awk -F ":" '{print $1}') 1) - ipset -q add $IPSET_VPS $ip + for item in $(uci show $CONFIG | grep ".lbss=" | cut -d "'" -f 2); do + local ip=$(get_host_ip "ipv4" "$(echo $item | awk -F ":" '{print $1}')" 1) + [ -n "$ip" ] && ! echo "$ip" | grep -Eq "$EXCLUDE_VPSIP" && ipset -q add $IPSET_VPS $ip done echolog " - [$?]加入负载均衡的节点到ipset[$IPSET_VPS]直连完成" } filter_vpsip() { - local EXCLUDE_VPSIP="^(0\.0\.0\.0|127\.0\.0\.1|1\.1\.1\.1|1\.1\.1\.2|8\.8\.8\.8|8\.8\.4\.4|9\.9\.9\.9)$" uci show $CONFIG | grep -E "(\.address=|\.download_address=|\.domain_resolver_dns=|\.domain_resolver_dns_https=)" | cut -d "'" -f 2 | grep -Eo "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -Ev "$EXCLUDE_VPSIP" | sed "s/^/add $IPSET_VPS /" | awk '1; END{print "COMMIT"}' | ipset -! -R echolog " - [$?]加入所有IPv4节点到ipset[$IPSET_VPS]直连完成" uci show $CONFIG | grep -E "(\.address=|\.download_address=|\.domain_resolver_dns=|\.domain_resolver_dns_https=)" | cut -d "'" -f 2 | grep -Eo "\[?[A-Fa-f0-9:]*:[A-Fa-f0-9:]+\]?" | sed "s/^/add $IPSET_VPS6 /" | awk '1; END{print "COMMIT"}' | ipset -! -R @@ -802,7 +802,9 @@ filter_node() { local port=$(config_n_get "$node" port) local hop=$(config_n_get "$node" hysteria2_hop) [ -n "$hop" ] && port="${port:+$port,}$hop" - [ -z "$address" ] || [ -z "$port" ] && return 1 + [ -z "$address" ] && return 1 + echo "$address" | grep -Eq "$EXCLUDE_VPSIP" && return 1 + [ -z "$port" ] && return 1 filter_server_port "$address" "$port" "$stream" } diff --git a/luci-app-passwall/root/usr/share/passwall/nftables.sh b/luci-app-passwall/root/usr/share/passwall/nftables.sh index 85135ee0..36fbf145 100755 --- a/luci-app-passwall/root/usr/share/passwall/nftables.sh +++ b/luci-app-passwall/root/usr/share/passwall/nftables.sh @@ -50,6 +50,7 @@ FAKE_IP="198.18.0.0/15" FAKE_IP_6="fc00::/18" USE_GEOVIEW=0 +EXCLUDE_VPSIP="^(0\.0\.0\.0|127\.0\.0\.1|1\.1\.1\.1|1\.1\.1\.2|8\.8\.8\.8|8\.8\.4\.4|9\.9\.9\.9)$" factor() { local ports="$1" @@ -809,24 +810,23 @@ load_acl() { } filter_haproxy() { - for item in ${haproxy_items}; do - get_host_ip ipv4 $(echo $item | awk -F ":" '{print $1}') 1 - done | insert_nftset $NFTSET_VPS + for item in $(uci show $CONFIG | grep ".lbss=" | cut -d "'" -f 2); do + get_host_ip "ipv4" "$(echo $item | awk -F ":" '{print $1}')" 1 + done | grep -Ev "$EXCLUDE_VPSIP" | insert_nftset $NFTSET_VPS echolog " - [$?]加入负载均衡的节点到nftset[$NFTSET_VPS]直连完成" } filter_vps_addr() { for server_host in "$@"; do - get_host_ip "ipv4" ${server_host} - done | insert_nftset $NFTSET_VPS + get_host_ip "ipv4" "${server_host}" + done | grep -Ev "$EXCLUDE_VPSIP" | insert_nftset $NFTSET_VPS for server_host in "$@"; do - get_host_ip "ipv6" ${server_host} + get_host_ip "ipv6" "${server_host}" done | insert_nftset $NFTSET_VPS6 } filter_vpsip() { - local EXCLUDE_VPSIP="^(0\.0\.0\.0|127\.0\.0\.1|1\.1\.1\.1|1\.1\.1\.2|8\.8\.8\.8|8\.8\.4\.4|9\.9\.9\.9)$" uci show $CONFIG | grep -E "(\.address=|\.download_address=|\.domain_resolver_dns=|\.domain_resolver_dns_https=)" | cut -d "'" -f 2 | grep -Eo "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -Ev "$EXCLUDE_VPSIP" | insert_nftset $NFTSET_VPS echolog " - [$?]加入所有IPv4节点到nftset[$NFTSET_VPS]直连完成" uci show $CONFIG | grep -E "(\.address=|\.download_address=|\.domain_resolver_dns=|\.domain_resolver_dns_https=)" | cut -d "'" -f 2 | grep -Eo "\[?[A-Fa-f0-9:]*:[A-Fa-f0-9:]+\]?" | insert_nftset $NFTSET_VPS6 @@ -864,7 +864,9 @@ filter_node() { local port=$(config_n_get "$node" port) local hop=$(config_n_get "$node" hysteria2_hop) [ -n "$hop" ] && port="${port:+$port,}$hop" - [ -z "$address" ] || [ -z "$port" ] && return 1 + [ -z "$address" ] && return 1 + echo "$address" | grep -Eq "$EXCLUDE_VPSIP" && return 1 + [ -z "$port" ] && return 1 filter_server_port "$address" "$port" "$stream" } @@ -877,7 +879,6 @@ filter_direct_node_list() { done } - del_script_mwan3() { [ -s "/etc/init.d/mwan3" ] && sed -i "/${CONFIG}/d" /etc/init.d/mwan3 >/dev/null 2>&1 } 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 b7aea51f..6277db7c 100755 --- a/luci-app-passwall/root/usr/share/passwall/rule_update.lua +++ b/luci-app-passwall/root/usr/share/passwall/rule_update.lua @@ -726,13 +726,21 @@ if geo2rule == "1" then end -- 如果是手动更新(arg2存在)始终生成规则 - if arg2 then geoip_update_ok, geosite_update_ok = true, true end - chnroute_update, chnroute6_update, gfwlist_update, chnlist_update = "1", "1", "1", "1" + if arg2 then + geoip_update_ok, geosite_update_ok = true, true + end + if not rollback then + chnroute_update, chnroute6_update, gfwlist_update, chnlist_update = "1", "1", "1", "1" + end if geoip_update_ok then if fs.access(asset_location .. "geoip.dat") then - safe_call(fetch_chnroute, "生成chnroute发生错误...") - safe_call(fetch_chnroute6, "生成chnroute6发生错误...") + if chnroute_update == "1" then + safe_call(fetch_chnroute, "生成chnroute发生错误...") + end + if chnroute6_update == "1" then + safe_call(fetch_chnroute6, "生成chnroute6发生错误...") + end else log("geoip.dat 文件不存在,跳过规则生成。") end @@ -740,8 +748,12 @@ if geo2rule == "1" then if geosite_update_ok then if fs.access(asset_location .. "geosite.dat") then - safe_call(fetch_gfwlist, "生成gfwlist发生错误...") - safe_call(fetch_chnlist, "生成chnlist发生错误...") + if gfwlist_update == "1" then + safe_call(fetch_gfwlist, "生成gfwlist发生错误...") + end + if chnlist_update == "1" then + safe_call(fetch_chnlist, "生成chnlist发生错误...") + end else log("geosite.dat 文件不存在,跳过规则生成。") end diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl_config.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl_config.lua index 3c9cc084..a0f69da5 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl_config.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl_config.lua @@ -271,7 +271,7 @@ o:depends("_show_dns_option", "1") ---- DNS over TCP or UDP or TLS (DoT) or QUIC (DoQ) o = s:option(Value, "remote_dns", translate("Remote DNS")) -o.datatype = "or(ipaddr,ipaddrport)" +o.datatype = "or(ipaddr,ipaddrport(1))" o.default = "1.1.1.1" o:value("1.1.1.1", "1.1.1.1 (CloudFlare)") o:value("1.1.1.2", "1.1.1.2 (CloudFlare-Security)") 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 92e6c13e..bc13be84 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua @@ -182,7 +182,7 @@ end ---- DNS over TCP or UDP or TLS (DoT) or QUIC (DoQ) o = s:taboption("DNS", Value, "remote_dns", translate("Remote DNS")) -o.datatype = "or(ipaddr,ipaddrport)" +o.datatype = "or(ipaddr,ipaddrport(1))" o.default = "1.1.1.1" o:value("1.1.1.1", "1.1.1.1 (CloudFlare)") o:value("1.1.1.2", "1.1.1.2 (CloudFlare-Security)") diff --git a/luci-app-passwall2/luasrc/passwall2/api.lua b/luci-app-passwall2/luasrc/passwall2/api.lua index 8e742b5f..029df932 100644 --- a/luci-app-passwall2/luasrc/passwall2/api.lua +++ b/luci-app-passwall2/luasrc/passwall2/api.lua @@ -2048,4 +2048,28 @@ function gen_wireguard_key() public_key = public_key } end -end \ No newline at end of file +end + +function parseDNS(dns) + if not dns then return nil end + if true then + -- IPv6 + -- [::1]:5053 + local address, port = dns:match("%[(.-)%]:([0-9]+)$") + if address and datatypes.ip6addr(address) and datatypes.port(port) then + return address, port + end + -- [::1] + if is_ipv6(dns) then + return get_ipv6_only(dns), 53 + end + end + if true then + -- 1.1.1.1:5053 + local h, p = dns:match("^([^:]+):([^:]+)$") + if (h and p and datatypes.ip4addr(h) and datatypes.port(p)) then + return h, p + end + end + return dns, 53 +end diff --git a/luci-app-passwall2/luasrc/passwall2/util_xray.lua b/luci-app-passwall2/luasrc/passwall2/util_xray.lua index e6fddd62..d9ac06a7 100644 --- a/luci-app-passwall2/luasrc/passwall2/util_xray.lua +++ b/luci-app-passwall2/luasrc/passwall2/util_xray.lua @@ -1623,8 +1623,6 @@ function gen_config(var) end end) end - - local _remote_dns_ip = nil local _remote_dns = { tag = remote_dns_tag, @@ -1635,14 +1633,15 @@ function gen_config(var) _remote_dns.address = remote_dns_udp_server _remote_dns.port = tonumber(remote_dns_udp_port) or 53 _remote_dns_proto = "udp" - _remote_dns_ip = remote_dns_udp_server end if remote_dns_tcp_server then + if api.is_ipv6(remote_dns_tcp_server) then + remote_dns_tcp_server = api.get_ipv6_full(remote_dns_tcp_server) + end _remote_dns.address = "tcp://" .. remote_dns_tcp_server .. ":" .. tonumber(remote_dns_tcp_port) or 53 _remote_dns.port = tonumber(remote_dns_tcp_port) or 53 _remote_dns_proto = "tcp" - _remote_dns_ip = remote_dns_tcp_server end if remote_dns_doh_url and remote_dns_doh_host then @@ -1651,7 +1650,6 @@ function gen_config(var) end _remote_dns.address = remote_dns_doh_url _remote_dns.port = tonumber(remote_dns_doh_port) or 443 - _remote_dns_ip = remote_dns_doh_ip end if _remote_dns.address then diff --git a/luci-app-passwall2/root/usr/share/passwall2/app.sh b/luci-app-passwall2/root/usr/share/passwall2/app.sh index e2148526..f309a83d 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/app.sh +++ b/luci-app-passwall2/root/usr/share/passwall2/app.sh @@ -69,7 +69,7 @@ check_run_environment() { run_xray() { local flag node 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 remote_dns_protocol remote_dns_udp_server remote_dns_tcp_server remote_dns_doh remote_dns_client_ip remote_dns_detour remote_fakedns remote_dns_query_strategy dns_cache + local dns_listen_port direct_dns_query_strategy remote_dns_protocol remote_dns_udp_server remote_dns_udp_port remote_dns_tcp_server remote_dns_tcp_port remote_dns_doh remote_dns_client_ip remote_dns_detour remote_fakedns remote_dns_query_strategy dns_cache local loglevel log_file config_file eval_set_val $@ node_protocol=$(config_n_get $node protocol) @@ -100,6 +100,7 @@ run_xray() { } } [ -n "$dns_listen_port" ] && { + local dns_msg="DNS[${dns_listen_port}]:($(i18n "Direct DNS: %s" "${AUTO_DNS}")" json_add_string "dns_listen_port" "${dns_listen_port}" [ -n "$dns_cache" ] && json_add_string "dns_cache" "${dns_cache}" [ "${node_protocol}" = "_shunt" ] && local write_ipset_direct=$(config_n_get $node write_ipset_direct 0) @@ -129,24 +130,16 @@ run_xray() { set_cache_var "node_${node}_direct_nftset6" "${direct_nftset6}" } } - [ "$remote_fakedns" = "1" ] && { - json_add_string "remote_dns_fake" "1" - json_add_string "remote_dns_fake_strategy" "${remote_dns_query_strategy}" - } case "$remote_dns_protocol" in udp) - local _dns=$(get_first_dns remote_dns_udp_server 53 | sed 's/#/:/g') - local _dns_address=$(echo ${_dns} | awk -F ':' '{print $1}') - local _dns_port=$(echo ${_dns} | awk -F ':' '{print $2}') - json_add_string "remote_dns_udp_port" "${_dns_port}" - json_add_string "remote_dns_udp_server" "${_dns_address}" + json_add_string "remote_dns_udp_server" "${remote_dns_udp_server}" + json_add_string "remote_dns_udp_port" "${remote_dns_udp_port}" + dns_msg="${dns_msg} $(i18n "Remote DNS: %s" "udp://${remote_dns_udp_server}:${remote_dns_udp_port}")" ;; tcp) - local _dns=$(get_first_dns remote_dns_tcp_server 53 | sed 's/#/:/g') - local _dns_address=$(echo ${_dns} | awk -F ':' '{print $1}') - local _dns_port=$(echo ${_dns} | awk -F ':' '{print $2}') - json_add_string "remote_dns_tcp_port" "${_dns_port}" - json_add_string "remote_dns_tcp_server" "${_dns_address}" + json_add_string "remote_dns_tcp_server" "${remote_dns_tcp_server}" + json_add_string "remote_dns_tcp_port" "${remote_dns_tcp_port}" + dns_msg="${dns_msg} $(i18n "Remote DNS: %s" "tcp://${remote_dns_tcp_server}:${remote_dns_tcp_port}")" ;; doh) local _doh_url=$(echo $remote_dns_doh | awk -F ',' '{print $1}') @@ -162,11 +155,18 @@ run_xray() { json_add_string "remote_dns_doh_url" "${_doh_url}" json_add_string "remote_dns_doh_host" "${_doh_host}" [ -n "$_doh_bootstrap" ] && json_add_string "remote_dns_doh_ip" "${_doh_bootstrap}" + dns_msg="${dns_msg} $(i18n "Remote DNS: %s" "${_doh_url}")" ;; esac + [ "$remote_fakedns" = "1" ] && { + json_add_string "remote_dns_fake" "1" + json_add_string "remote_dns_fake_strategy" "${remote_dns_query_strategy}" + dns_msg="${dns_msg} + FakeDNS " + } [ -n "$remote_dns_detour" ] && json_add_string "remote_dns_detour" "${remote_dns_detour}" [ -n "$remote_dns_query_strategy" ] && json_add_string "remote_dns_query_strategy" "${remote_dns_query_strategy}" [ -n "$remote_dns_client_ip" ] && json_add_string "remote_dns_client_ip" "${remote_dns_client_ip}" + log_out="${dns_msg})" } json_add_string "direct_dns_udp_port" "${DIRECT_DNS_UDP_PORT}" json_add_string "direct_dns_udp_server" "${DIRECT_DNS_UDP_SERVER}" @@ -176,6 +176,7 @@ run_xray() { json_add_string "redir_port" "${redir_port}" set_cache_var "node_${node}_redir_port" "${redir_port}" json_add_string "tcp_proxy_way" "${TCP_PROXY_WAY}" + [ -n "${log_out}" ] && log_out="Xray[${redir_port}] ${log_out}" } json_add_string "node" "${node}" @@ -189,6 +190,8 @@ run_xray() { $XRAY_BIN run -test -c "$config_file" > $test_log_file; local status=$? if [ "${status}" == 0 ]; then ln_run ${QUEUE_RUN} "$XRAY_BIN" xray $log_file run -c "$config_file" + [ -n "${log_out}" ] && log 2 ${log_out} + unset log_out else _error_log_file=$test_log_file return ${status} @@ -197,7 +200,7 @@ run_xray() { run_singbox() { local flag node 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 remote_dns_protocol remote_dns_udp_server remote_dns_tcp_server remote_dns_doh remote_dns_client_ip remote_dns_detour remote_fakedns remote_dns_query_strategy remote_rewrite_ttl dns_cache + local dns_listen_port direct_dns_query_strategy remote_dns_protocol remote_dns_udp_server remote_dns_udp_port remote_dns_tcp_server remote_dns_tcp_port remote_dns_doh remote_dns_client_ip remote_dns_detour remote_fakedns remote_dns_query_strategy remote_rewrite_ttl dns_cache local loglevel log_file config_file eval_set_val $@ local type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z') @@ -239,6 +242,9 @@ run_singbox() { } } [ -n "$dns_listen_port" ] && { + local dns_msg="DNS[${dns_listen_port}]:($(i18n "Direct DNS: %s" "${AUTO_DNS}")" + json_add_string "dns_listen_port" "${dns_listen_port}" + [ -n "$dns_cache" ] && json_add_string "dns_cache" "${dns_cache}" [ "${node_protocol}" = "_shunt" ] && local write_ipset_direct=$(config_n_get $node write_ipset_direct 0) [ "${write_ipset_direct}" = "1" ] && { direct_dnsmasq_listen_port=$(get_new_port auto) @@ -270,21 +276,17 @@ run_singbox() { case "$remote_dns_protocol" in udp|\ quic) - local _dns=$(get_first_dns remote_dns_udp_server 53 | sed 's/#/:/g') - local _dns_address=$(echo ${_dns} | awk -F ':' '{print $1}') - local _dns_port=$(echo ${_dns} | awk -F ':' '{print $2}') - json_add_string "remote_dns_udp_port" "${_dns_port}" - json_add_string "remote_dns_udp_server" "${_dns_address}" + json_add_string "remote_dns_udp_server" "${remote_dns_udp_server}" + json_add_string "remote_dns_udp_port" "${remote_dns_udp_port}" [ "$remote_dns_protocol" == "quic" ] && json_add_string "remote_dns_quic" "1" + dns_msg="${dns_msg} $(i18n "Remote DNS: %s" "${remote_dns_protocol}://${remote_dns_udp_server}:${remote_dns_udp_port}")" ;; tcp|\ tls) - local _dns=$(get_first_dns remote_dns_tcp_server 53 | sed 's/#/:/g') - local _dns_address=$(echo ${_dns} | awk -F ':' '{print $1}') - local _dns_port=$(echo ${_dns} | awk -F ':' '{print $2}') - json_add_string "remote_dns_tcp_port" "${_dns_port}" - json_add_string "remote_dns_tcp_server" "${_dns_address}" + json_add_string "remote_dns_tcp_server" "${remote_dns_tcp_server}" + json_add_string "remote_dns_tcp_port" "${remote_dns_tcp_port}" [ "$remote_dns_protocol" == "tls" ] && json_add_string "remote_dns_tls" "1" + dns_msg="${dns_msg} $(i18n "Remote DNS: %s" "${remote_dns_protocol}://${remote_dns_tcp_server}:${remote_dns_tcp_port}")" ;; doh|\ http3) @@ -302,17 +304,19 @@ run_singbox() { json_add_string "remote_dns_doh_url" "${_doh_url}" json_add_string "remote_dns_doh_host" "${_doh_host}" [ "$remote_dns_protocol" == "http3" ] && json_add_string "remote_dns_http3" "1" + dns_msg="${dns_msg} $(i18n "Remote DNS: %s" "${_doh_url}")" ;; esac + [ "$remote_fakedns" = "1" ] && { + json_add_string "remote_dns_fake" "1" + dns_msg="${dns_msg} + FakeDNS " + } [ -n "$remote_dns_detour" ] && json_add_string "remote_dns_detour" "${remote_dns_detour}" [ -n "$remote_dns_query_strategy" ] && json_add_string "remote_dns_query_strategy" "${remote_dns_query_strategy}" [ -n "$remote_dns_client_ip" ] && json_add_string "remote_dns_client_ip" "${remote_dns_client_ip}" - - [ -n "$dns_listen_port" ] && json_add_string "dns_listen_port" "${dns_listen_port}" - [ -n "$dns_cache" ] && json_add_string "dns_cache" "${dns_cache}" - [ "$remote_fakedns" = "1" ] && json_add_string "remote_dns_fake" "1" [ -n "$remote_rewrite_ttl" ] && json_add_string "remote_rewrite_ttl" "${remote_rewrite_ttl}" + log_out="${dns_msg})" } json_add_string "direct_dns_udp_port" "${DIRECT_DNS_UDP_PORT}" json_add_string "direct_dns_udp_server" "${DIRECT_DNS_UDP_SERVER}" @@ -322,6 +326,7 @@ run_singbox() { json_add_string "redir_port" "${redir_port}" set_cache_var "node_${node}_redir_port" "${redir_port}" json_add_string "tcp_proxy_way" "${TCP_PROXY_WAY}" + [ -n "${log_out}" ] && log_out="Sing-Box[${redir_port}] ${log_out}" } json_add_string "node" "${node}" @@ -335,6 +340,8 @@ run_singbox() { $SINGBOX_BIN check -c "$config_file" > $test_log_file 2>&1; local status=$? if [ "${status}" == 0 ]; then ln_run ${QUEUE_RUN} "$SINGBOX_BIN" "sing-box" "${log_file}" run -c "$config_file" + [ -n "${log_out}" ] && log 2 ${log_out} + unset log_out else _error_log_file=$test_log_file return ${status} @@ -803,13 +810,28 @@ run_ipset_dnsmasq() { } acl_node() { + [ ! -f ${TMP_ACL_PATH}/acl_node_default ] && ENABLED_DEFAULT_ACL=0 + local acl_node_num=$(jsonfilter -s "${acl_json}" -e '$.node_order[*]' | wc -l) + [ "${acl_node_num}" == 0 ] && { + ENABLED_DEFAULT_ACL=0 + ENABLED_ACLS=0 + return + } + [ "$(uci -q get dhcp.@dnsmasq[0].dns_redirect)" == "1" ] && { + uci -q set ${CONFIG}.@global[0].dnsmasq_dns_redirect='1' + uci -q commit ${CONFIG} + uci -q set dhcp.@dnsmasq[0].dns_redirect='0' + uci -q commit dhcp + + json_init + json_add_string "LOG" "0" + lua $APP_PATH/helper_dnsmasq.lua restart "$(json_dump)" + } local run_func [ -n "${XRAY_BIN}" ] && run_func="run_xray" [ -n "${SINGBOX_BIN}" ] && run_func="run_singbox" - local acl_node_num=0 for nid in $(jsonfilter -s "${acl_json}" -e '$.node_order[*]'); do [ ! -f ${TMP_ACL_PATH}/acl_node_${nid} ] && continue - acl_node_num=$(expr $acl_node_num + 1) local _var=$(cat ${TMP_ACL_PATH}/acl_node_${nid} 2>/dev/null) eval local ${_var} local type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z') @@ -851,26 +873,24 @@ acl_node() { uci -q add_list dhcp.@dnsmasq[0].addnmount=${GLOBAL_DNSMASQ_CONF_PATH} uci -q commit dhcp - json_init - json_add_string "LOG" "1" - lua $APP_PATH/helper_dnsmasq.lua logic_restart "$(json_dump)" + lua $APP_PATH/helper_dnsmasq.lua logic_restart else #Run a copy dnsmasq instance, DNS hijack for that need proxy devices. dnsmasq_port=$(get_new_port auto) run_copy_dnsmasq flag="default" listen_port=${dnsmasq_port} local_dns="${DNSMASQ_LOCAL_DNS}" tun_dns="${DNSMASQ_TUN_DNS}" default_dns="${DNSMASQ_DEFAULT_DNS}" #dhcp.leases to hosts $APP_PATH/lease2hosts.sh > /dev/null 2>&1 & + log 2 "Dnsmasq[${dnsmasq_port}]:(127.0.0.1:${dns_listen_port})" fi else dnsmasq_port=$(get_new_port auto) run_copy_dnsmasq flag="${flag}" listen_port=${dnsmasq_port} local_dns="${LOCAL_DNS:-${AUTO_DNS}}" tun_dns="127.0.0.1#${dns_listen_port}" default_dns="${AUTO_DNS}" #dhcp.leases to hostsMore actions $APP_PATH/lease2hosts.sh > /dev/null 2>&1 & + log 2 "Dnsmasq[${dnsmasq_port}]:(127.0.0.1:${dns_listen_port})" fi rm -f ${TMP_ACL_PATH}/acl_node_${nid} done - [ ! -f ${TMP_ACL_PATH}/acl_node_default ] && ENABLED_DEFAULT_ACL=0 - [ "${acl_node_num}" == 0 ] && ENABLED_ACLS=0 && ENABLED_DEFAULT_ACL=0 } start() { @@ -892,16 +912,6 @@ start() { nftflag=0 USE_TABLES="" check_run_environment - [ "$(uci -q get dhcp.@dnsmasq[0].dns_redirect)" == "1" ] && { - uci -q set ${CONFIG}.@global[0].dnsmasq_dns_redirect='1' - uci -q commit ${CONFIG} - uci -q set dhcp.@dnsmasq[0].dns_redirect='0' - uci -q commit dhcp - - json_init - json_add_string "LOG" "0" - lua $APP_PATH/helper_dnsmasq.lua restart "$(json_dump)" - } [ -n "$USE_TABLES" ] && source $APP_PATH/${USE_TABLES}.sh start set_cache_var "USE_TABLES" "$USE_TABLES" if [ "$ENABLED_DEFAULT_ACL" == 1 ] || [ "$ENABLED_ACLS" == 1 ]; then diff --git a/luci-app-passwall2/root/usr/share/passwall2/app_acl.lua b/luci-app-passwall2/root/usr/share/passwall2/app_acl.lua index 8ea9b985..a4acbe96 100644 --- a/luci-app-passwall2/root/usr/share/passwall2/app_acl.lua +++ b/luci-app-passwall2/root/usr/share/passwall2/app_acl.lua @@ -191,6 +191,7 @@ function acl_app(l) local config_path = api.TMP_ACL_PATH .. "/" .. flag local config_file = config_path .. ".json" local log_file = v.log == "0" and "/dev/null" or config_path .. ".log" + local dns_server, dns_port = api.parseDNS(v.remote_dns) add_args(run_args, "flag", flag) add_args(run_args, "node", node[".name"]) add_args(run_args, "redir_port", v.redir_port) @@ -199,8 +200,10 @@ function acl_app(l) add_args(run_args, "dns_listen_port", v.dns_port) add_args(run_args, "direct_dns_query_strategy", v.direct_dns_query_strategy) add_args(run_args, "remote_dns_protocol", v.remote_dns_protocol) - add_args(run_args, "remote_dns_tcp_server", v.remote_dns) - add_args(run_args, "remote_dns_udp_server", v.remote_dns) + add_args(run_args, "remote_dns_tcp_server", dns_server) + add_args(run_args, "remote_dns_tcp_port", dns_port) + add_args(run_args, "remote_dns_udp_server", dns_server) + add_args(run_args, "remote_dns_udp_port", dns_port) add_args(run_args, "remote_dns_doh", v.remote_dns_doh) add_args(run_args, "remote_dns_client_ip", v.remote_dns_client_ip) add_args(run_args, "remote_dns_detour", v.remote_dns_detour) diff --git a/luci-app-passwall2/root/usr/share/passwall2/helper_dnsmasq.lua b/luci-app-passwall2/root/usr/share/passwall2/helper_dnsmasq.lua index 911f009b..f3ce59d7 100644 --- a/luci-app-passwall2/root/usr/share/passwall2/helper_dnsmasq.lua +++ b/luci-app-passwall2/root/usr/share/passwall2/helper_dnsmasq.lua @@ -366,6 +366,6 @@ if arg[1] then if arg[2] then var = jsonc.parse(arg[2]) end - func(var) + func(var or {}) end end diff --git a/luci-app-passwall2/root/usr/share/passwall2/iptables.sh b/luci-app-passwall2/root/usr/share/passwall2/iptables.sh index 81d52c2c..828a57a0 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/iptables.sh +++ b/luci-app-passwall2/root/usr/share/passwall2/iptables.sh @@ -256,9 +256,9 @@ add_shunt_t_rule() { } load_acl() { + log_i18n 1 "Access Control:" acl_json=$(lua $APP_PATH/app_acl.lua) acl_node - log_i18n 1 "Access Control:" for sid in $(jsonfilter -s "${acl_json}" -e '$.acl[*].flag'); do eval local $(cat "${TMP_ACL_PATH}/${sid}/var") diff --git a/luci-app-passwall2/root/usr/share/passwall2/nftables.sh b/luci-app-passwall2/root/usr/share/passwall2/nftables.sh index 950d114e..e4378371 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/nftables.sh +++ b/luci-app-passwall2/root/usr/share/passwall2/nftables.sh @@ -294,9 +294,9 @@ add_shunt_t_rule() { } load_acl() { + log_i18n 1 "Access Control:" acl_json=$(lua $APP_PATH/app_acl.lua) acl_node - log_i18n 1 "Access Control:" for sid in $(jsonfilter -s "${acl_json}" -e '$.acl[*].flag'); do eval $(cat "${TMP_ACL_PATH}/${sid}/var") diff --git a/luci-app-passwall2/root/usr/share/passwall2/utils.sh b/luci-app-passwall2/root/usr/share/passwall2/utils.sh index 84cb7da4..68db5cd6 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/utils.sh +++ b/luci-app-passwall2/root/usr/share/passwall2/utils.sh @@ -253,28 +253,6 @@ hosts_foreach() { done } -get_first_dns() { - local __hosts_val=${1}; shift 1 - __first() { - [ -z "${2}" ] && return 0 - echo "${2}#${3}" - return 1 - } - eval "hosts_foreach \"${__hosts_val}\" __first \"$@\"" -} - -get_last_dns() { - local __hosts_val=${1}; shift 1 - local __first __last - __every() { - [ -z "${2}" ] && return 0 - __last="${2}#${3}" - __first=${__first:-${__last}} - } - eval "hosts_foreach \"${__hosts_val}\" __every \"$@\"" - [ "${__first}" == "${__last}" ] || echo "${__last}" -} - check_port_exists() { local port=$1 local protocol=$2 diff --git a/luci-app-syncthing/Makefile b/luci-app-syncthing/Makefile deleted file mode 100644 index 2219fcb2..00000000 --- a/luci-app-syncthing/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (C) 2020 Gyj1109 -# 适配 OpenWrt 25.12 修改版 - -include $(TOPDIR)/rules.mk - -PKG_NAME:=luci-app-syncthing -PKG_VERSION:=1.0 -PKG_RELEASE:=3 - -LUCI_TITLE:=LuCI support for Syncthing -LUCI_PKGARCH:=all -# 适配 25.12:确保安装了 syncthing 后,LuCI 界面能正确拉起 -LUCI_DEPENDS:=+syncthing - -include $(TOPDIR)/feeds/luci/luci.mk - -# 明确定义配置文件的归属,这对 25.12 的 apk 管理器非常重要 -define Package/$(PKG_NAME)/conffiles -/etc/config/syncthing -endef - -$(eval $(call BuildPackage,$(PKG_NAME))) diff --git a/luci-app-syncthing/README.md b/luci-app-syncthing/README.md deleted file mode 100644 index b07298c1..00000000 --- a/luci-app-syncthing/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# luci-app-syncthing -在Potat0000源码基础上进行了汉化优化,官方openwrt23.05.3编译后可使用 diff --git a/luci-app-syncthing/luasrc/controller/syncthing.lua b/luci-app-syncthing/luasrc/controller/syncthing.lua deleted file mode 100644 index ee2ca7ef..00000000 --- a/luci-app-syncthing/luasrc/controller/syncthing.lua +++ /dev/null @@ -1,17 +0,0 @@ -module("luci.controller.syncthing", package.seeall) - -function index() - if not nixio.fs.access("/etc/config/syncthing") then - return - end - - entry({"admin", "services", "syncthing"}, cbi("syncthing"), _("文件同步"), 10).dependent = true - entry({"admin", "services", "syncthing", "status"}, call("act_status")).leaf = true -end - -function act_status() - local e = {} - e.running = luci.sys.call("pgrep syncthing >/dev/null") == 0 - luci.http.prepare_content("application/json") - luci.http.write_json(e) -end diff --git a/luci-app-syncthing/luasrc/model/cbi/syncthing.lua b/luci-app-syncthing/luasrc/model/cbi/syncthing.lua deleted file mode 100644 index 324ea054..00000000 --- a/luci-app-syncthing/luasrc/model/cbi/syncthing.lua +++ /dev/null @@ -1,48 +0,0 @@ -require("nixio.fs") - -m = Map("syncthing", translate("Syncthing同步工具")) - -m:section(SimpleSection).template = "syncthing/syncthing_status" - -s = m:section(TypedSection, "syncthing") - -s.anonymous = true - -o = s:option(Flag, "enabled", translate("启用")) -o.default = 0 -o.rmempty = false - -gui_address = s:option(Value, "gui_address", translate("GUI访问地址")) -gui_address.description = translate("使用0.0.0.0以监控所有访问。") -gui_address.default = "http://0.0.0.0:8384" -gui_address.placeholder = "http://0.0.0.0:8384" -gui_address.rmempty = false - -home = s:option(Value, "home", translate("配置文件目录")) -home.description = translate("只有保存在/etc/syncthing中的配置会自动备份!") -home.default = "/etc/syncthing" -home.placeholder = "/etc/syncthing" -home.rmempty = false - -user = s:option(ListValue, "user", translate("用户")) -user.description = translate("默认是syncthing,但这可能会导致权限被拒绝。Syncthing官方不建议以root身份运行。") -user:value("", translate("syncthing")) -for u in luci.util.execi("cat /etc/passwd | cut -d ':' -f1") do - user:value(u) -end - -macprocs = s:option(Value, "macprocs", translate("线程限制")) -macprocs.description = translate("0表示匹配CPU数量(默认),>0表示显式指定并发数。") -macprocs.default = "0" -macprocs.placeholder = "0" -macprocs.datatype = "range(0,32)" -macprocs.rmempty = false - -nice = s:option(Value, "nice", translate("优先级")) -nice.description = translate("显式指定优先级值。0是最高,19是最低。(暂时不允许设置负值)") -nice.default = "19" -nice.placeholder = "19" -nice.datatype = "range(0,19)" -nice.rmempty = false - -return m diff --git a/luci-app-syncthing/luasrc/view/syncthing/syncthing_status.htm b/luci-app-syncthing/luasrc/view/syncthing/syncthing_status.htm deleted file mode 100644 index 566cc020..00000000 --- a/luci-app-syncthing/luasrc/view/syncthing/syncthing_status.htm +++ /dev/null @@ -1,27 +0,0 @@ - - -
-

- <%:正在收集数据...%> -

-
diff --git a/luci-app-syncthing/root/etc/uci-defaults/luci-syncthing b/luci-app-syncthing/root/etc/uci-defaults/luci-syncthing deleted file mode 100644 index 3adb7997..00000000 --- a/luci-app-syncthing/root/etc/uci-defaults/luci-syncthing +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -touch /etc/config/syncthing - -uci -q batch <<-EOF >/dev/null - delete ucitrack.@syncthing[-1] - add ucitrack syncthing - set ucitrack.@syncthing[-1].exec='/etc/init.d/syncthing stop && /etc/init.d/syncthing start' - commit ucitrack -EOF -# remove LuCI cache -rm -f /tmp/luci* -exit 0 diff --git a/luci-app-syncthing/root/usr/share/rpcd/acl.d/luci-app-syncthing.json b/luci-app-syncthing/root/usr/share/rpcd/acl.d/luci-app-syncthing.json deleted file mode 100644 index 9fc9cc54..00000000 --- a/luci-app-syncthing/root/usr/share/rpcd/acl.d/luci-app-syncthing.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "luci-app-syncthing": { - "description": "Grant UCI access for luci-app-syncthing", - "read": { - "uci": [ "syncthing" ] - }, - "write": { - "uci": [ "syncthing" ] - } - } -}