From fa527e2e56e1e50954f0e0f1fbb5e0e27e358deb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 9 Apr 2026 03:05:33 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=8B=20Sync=202026-04-09=2003:05:33?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/cbi/passwall/client/global.lua | 2 +- luci-app-passwall/po/zh-cn/passwall.po | 4 +- .../root/usr/share/passwall/adblock.sh | 12 ++++ .../root/usr/share/passwall/app.sh | 69 +++++++++---------- 4 files changed, 48 insertions(+), 39 deletions(-) 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 13cb4f59..76693a3d 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua @@ -566,7 +566,7 @@ o = s:taboption("DNS", DynamicList, "ad_url", translate("Anti-AD Rules Subscribe o:value("https://cdn.jsdelivr.net/gh/privacy-protection-tools/anti-AD/anti-ad-domains.txt", translate("anti-AD")) o:value("https://cdn.jsdelivr.net/gh/neodevpro/neodevhost/domain", translate("NEO DEV HOST")) o.default = "https://cdn.jsdelivr.net/gh/privacy-protection-tools/anti-AD/anti-ad-domains.txt" -o.description = translate("Support Domain and Dnsmasq format list") +o.description = translate("Support Domain / Dnsmasq / Hosts format list") o:depends("adblock",1) s:tab("Proxy", translate("Mode")) diff --git a/luci-app-passwall/po/zh-cn/passwall.po b/luci-app-passwall/po/zh-cn/passwall.po index 65851ca5..18d3ecc3 100644 --- a/luci-app-passwall/po/zh-cn/passwall.po +++ b/luci-app-passwall/po/zh-cn/passwall.po @@ -31,8 +31,8 @@ msgstr "上一次规则更新时间" msgid "Subscribe Rules Data" msgstr "去广告规则" -msgid "Support Domain and Dnsmasq format list" -msgstr "支持域名和Dnsmasq格式的过滤列表" +msgid "Support Domain / Dnsmasq / Hosts format list" +msgstr "支持 域名/Dnsmasq/Hosts 格式的过滤列表" msgid "Anti-AD Rules Subscribe" msgstr "广告过滤列表URL" diff --git a/luci-app-passwall/root/usr/share/passwall/adblock.sh b/luci-app-passwall/root/usr/share/passwall/adblock.sh index 1cc97c90..18abed5d 100755 --- a/luci-app-passwall/root/usr/share/passwall/adblock.sh +++ b/luci-app-passwall/root/usr/share/passwall/adblock.sh @@ -57,6 +57,8 @@ process_url() { sample_count++ if (fmt == "" && $0 ~ /^address=\/[^\/]+\//) fmt = "dnsmasq" if (fmt == "" && $0 ~ /^DOMAIN-SUFFIX,/) fmt = "clash" + if (fmt == "" && $0 ~ /^(0\.0\.0\.0|127\.0\.0\.1)[[:space:]]/) + fmt = "hosts" if (fmt == "" && $0 ~ /^[a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?)+$/) fmt = "plain" } @@ -68,6 +70,16 @@ process_url() { if (n >= 3 && a[1] == "address=") print a[2] } else if (fmt == "clash") { if (sub(/^DOMAIN-SUFFIX,/, "")) print + } else if (fmt == "hosts") { + # 0.0.0.0 domain.com 或 127.0.0.1 domain.com + if ($0 ~ /^(0\.0\.0\.0|127\.0\.0\.1)[[:space:]]/) { + domain = $2 + # 去掉行尾可能的注释 + gsub(/#.*/, "", domain) + gsub(/[[:space:]]/, "", domain) + if (domain != "" && domain != "localhost") + print domain + } } else if (fmt == "plain") { if ($0 ~ /^[a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?)+$/) print diff --git a/luci-app-passwall/root/usr/share/passwall/app.sh b/luci-app-passwall/root/usr/share/passwall/app.sh index 7a5290c4..c2749cfe 100755 --- a/luci-app-passwall/root/usr/share/passwall/app.sh +++ b/luci-app-passwall/root/usr/share/passwall/app.sh @@ -17,6 +17,8 @@ UTIL_TROJAN=$LUA_UTIL_PATH/util_trojan.lua UTIL_NAIVE=$LUA_UTIL_PATH/util_naiveproxy.lua UTIL_HYSTERIA2=$LUA_UTIL_PATH/util_hysteria2.lua UTIL_TUIC=$LUA_UTIL_PATH/util_tuic.lua +SINGBOX_BIN=$(first_type $(config_t_get global_app sing_box_file) sing-box) +XRAY_BIN=$(first_type $(config_t_get global_app xray_file) xray) check_run_environment() { local prefer_nft=$(config_t_get global_forwarding prefer_nft 1) @@ -102,11 +104,8 @@ run_singbox() { local loglevel log_file config_file server_host server_port no_run eval_set_val $@ [ -z "$type" ] && { - local type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z') - if [ "$type" != "sing-box" ]; then - bin=$(first_type $(config_t_get global_app sing_box_file) sing-box) - [ -n "$bin" ] && type="sing-box" - fi + type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z') + [ "$type" != "sing-box" ] && [ -n "$SINGBOX_BIN" ] && type="sing-box" } [ -z "$type" ] && return 1 [ -n "$log_file" ] || local log_file="/dev/null" @@ -187,7 +186,7 @@ run_singbox() { [ -n "$no_run" ] && json_add_string "no_run" "1" local _json_arg="$(json_dump)" lua $UTIL_SINGBOX gen_config "${_json_arg}" > $config_file - [ -n "$no_run" ] || ln_run "$(first_type $(config_t_get global_app sing_box_file) sing-box)" "sing-box" $log_file run -c "$config_file" + [ -n "$no_run" ] || ln_run "$SINGBOX_BIN" "sing-box" $log_file run -c "$config_file" } run_xray() { @@ -196,11 +195,8 @@ run_xray() { local loglevel log_file config_file server_host server_port no_run eval_set_val $@ [ -z "$type" ] && { - local type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z') - if [ "$type" != "xray" ]; then - bin=$(first_type $(config_t_get global_app xray_file) xray) - [ -n "$bin" ] && type="xray" - fi + type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z') + [ "$type" != "xray" ] && [ -n "$XRAY_BIN" ] && type="xray" } [ -z "$type" ] && return 1 json_init @@ -279,7 +275,7 @@ run_xray() { [ -n "$no_run" ] && json_add_string "no_run" "1" local _json_arg="$(json_dump)" lua $UTIL_XRAY gen_config "${_json_arg}" > $config_file - [ -n "$no_run" ] || ln_run "$(first_type $(config_t_get global_app ${type}_file) ${type})" ${type} $log_file run -c "$config_file" + [ -n "$no_run" ] || ln_run "$XRAY_BIN" "xray" $log_file run -c "$config_file" } run_dns2socks() { @@ -409,19 +405,20 @@ run_socks() { json_add_string "server_port" "${_socks_port}" json_add_string "server_username" "${_socks_username}" json_add_string "server_password" "${_socks_password}" - local bin=$(first_type $(config_t_get global_app sing_box_file) sing-box) - if [ -n "$bin" ]; then + if [ -n "${SINGBOX_BIN}" ]; then type="sing-box" - lua $UTIL_SINGBOX gen_proto_config "$(json_dump)" > $config_file - ln_run "$bin" ${type} $log_file run -c "$config_file" - else - bin=$(first_type $(config_t_get global_app xray_file) xray) - [ -n "$bin" ] && { - type="xray" - lua $UTIL_XRAY gen_proto_config "$(json_dump)" > $config_file - ln_run "$bin" ${type} $log_file run -c "$config_file" - } + local bin="${SINGBOX_BIN}" + local util="${UTIL_SINGBOX}" + elif [ -n "${XRAY_BIN}" ]; then + type="xray" + local bin="${XRAY_BIN}" + local util="${UTIL_XRAY}" fi + [ -n "${bin}" ] && [ -n "${util}" ] && { + lua ${util} gen_proto_config "$(json_dump)" > $config_file + [ -n "$no_run" ] || ln_run "$bin" $type $log_file run -c "$config_file" + } + unset bin util ;; sing-box) [ "$http_port" != "0" ] && { @@ -514,10 +511,7 @@ run_socks() { # http to socks [ -z "$http_flag" ] && [ "$http_port" != "0" ] && [ -n "$http_config_file" ] && [ "$type" != "sing-box" ] && [ "$type" != "xray" ] && [ "$type" != "socks" ] && { - local bin=$(first_type $(config_t_get global_app sing_box_file) sing-box) - json_add_null "node" - json_add_null "server_host" - json_add_null "server_port" + json_init json_add_string "local_http_address" "$bind" json_add_string "local_http_port" "$http_port" json_add_string "server_proto" "socks" @@ -525,17 +519,20 @@ run_socks() { json_add_string "server_port" "$socks_port" json_add_string "server_username" "$_username" json_add_string "server_password" "$_password" - if [ -n "$bin" ]; then + if [ -n "${SINGBOX_BIN}" ]; then type="sing-box" - lua $UTIL_SINGBOX gen_proto_config "$(json_dump)" > $http_config_file - [ -n "$no_run" ] || ln_run "$bin" ${type} /dev/null run -c "$http_config_file" - else - bin=$(first_type $(config_t_get global_app xray_file) xray) - [ -n "$bin" ] && type="xray" - [ -z "$type" ] && return 1 - lua $UTIL_XRAY gen_proto_config "$(json_dump)" > $http_config_file - [ -n "$no_run" ] || ln_run "$bin" ${type} /dev/null run -c "$http_config_file" + local bin="${SINGBOX_BIN}" + local util="${UTIL_SINGBOX}" + elif [ -n "${XRAY_BIN}" ]; then + type="xray" + local bin="${XRAY_BIN}" + local util="${UTIL_XRAY}" fi + [ -n "${bin}" ] && [ -n "${util}" ] && { + lua ${util} gen_proto_config "$(json_dump)" > $http_config_file + [ -n "$no_run" ] || ln_run "$bin" $type /dev/null run -c "$http_config_file" + } + unset bin util } unset http_flag