diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe.lua
index c76076de..a13e46ee 100644
--- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe.lua
+++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe.lua
@@ -112,14 +112,6 @@ if #ss_type > 0 or #trojan_type > 0 or #vmess_type > 0 or #vless_type > 0 or #hy
translate("The configured type also applies to the core specified when manually importing nodes."))
end
-o = s:option(ListValue, "domain_strategy", "Sing-box " .. translate("Domain Strategy"), translate("Set the default domain resolution strategy for the sing-box node."))
-o.default = ""
-o:value("", translate("Auto"))
-o:value("prefer_ipv4", translate("Prefer IPv4"))
-o:value("prefer_ipv6", translate("Prefer IPv6"))
-o:value("ipv4_only", translate("IPv4 Only"))
-o:value("ipv6_only", translate("IPv6 Only"))
-
---- Subscribe Delete All
o = s:option(DummyValue, "_stop", translate("Delete All Subscribe Node"))
o.rawhtml = true
diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe_config.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe_config.lua
index 31690099..6be6bacf 100644
--- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe_config.lua
+++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_subscribe_config.lua
@@ -127,6 +127,34 @@ o.validate = function(self, value)
return value:gsub("%s+", ""):gsub("%z", "")
end
+o = s:option(ListValue, "domain_resolver", translate("Domain DNS Resolve"))
+o.description = translate("If the node address is a domain name, this DNS will be used for resolution.") .. "
" ..
+ translate("Supports only Xray or Sing-box node types.")
+o:value("", translate("Auto"))
+o:value("tcp", "TCP")
+o:value("udp", "UDP")
+o:value("https", "DoH")
+
+o = s:option(Value, "domain_resolver_dns", "DNS")
+o.datatype = "or(ipaddr,ipaddrport)"
+o:value("114.114.114.114")
+o:value("223.5.5.5:53")
+o.default = o.keylist[1]
+o:depends({ domain_resolver = "tcp" })
+o:depends({ domain_resolver = "udp" })
+
+o = s:option(Value, "domain_resolver_dns_https", "DNS")
+o:value("https://120.53.53.53/dns-query", "DNSPod")
+o:value("https://223.5.5.5/dns-query", "AliDNS")
+o.default = o.keylist[1]
+o:depends({ domain_resolver = "https" })
+
+o = s:option(ListValue, "domain_strategy", translate("Domain Strategy"), translate("If is domain name, The requested domain name will be resolved to IP before connect."))
+o.default = ""
+o:value("", translate("Auto"))
+o:value("UseIPv4", translate("IPv4 Only"))
+o:value("UseIPv6", translate("IPv6 Only"))
+
o = s:option(Flag, "allowInsecure", translate("allowInsecure"))
o.default = "0"
o.rmempty = false
@@ -197,15 +225,6 @@ if #hysteria2_type > 0 then
end
end
-o = s:option(ListValue, "domain_strategy", "Sing-box " .. translate("Domain Strategy"), translate("Set the default domain resolution strategy for the sing-box node."))
-o.default = "global"
-o:value("global", translate("Use global config"))
-o:value("", translate("Auto"))
-o:value("prefer_ipv4", translate("Prefer IPv4"))
-o:value("prefer_ipv6", translate("Prefer IPv6"))
-o:value("ipv4_only", translate("IPv4 Only"))
-o:value("ipv6_only", translate("IPv6 Only"))
-
o = s:option(Flag, "boot_update", translate("Update Once on Boot"), translate("Updates the subscription the first time runs automatically after each system boot."))
o.default = 0
diff --git a/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua b/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua
index b454278d..68b13073 100644
--- a/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua
+++ b/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua
@@ -1094,7 +1094,7 @@ function gen_config(var)
end
function parse_rule_set(w, rs)
- -- Format: remote:https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geosite/geosite-netflix.srs'
+ -- Format: remote:https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-netflix.srs'
-- Format: local:/usr/share/sing-box/geosite-netflix.srs'
local result = nil
if w and #w > 0 then
@@ -1768,7 +1768,25 @@ function gen_config(var)
reverse_mapping = true, -- After responding to a DNS query, a reverse mapping of the IP address is stored to provide the domain name for routing purposes.
}
+ table.insert(dns.servers, {
+ type = "local",
+ tag = "local"
+ })
+
+ if direct_dns_udp_server then
+ table.insert(dns.servers, {
+ tag = "direct",
+ type = "udp",
+ server = direct_dns_udp_server,
+ server_port = tonumber(direct_dns_udp_port) or 53,
+ detour = "direct",
+ })
+ end
+
for i, v in pairs(GLOBAL.DNS_SERVER) do
+ if direct_dns_udp_server then
+ v.server.domain_resolver = "direct"
+ end
table.insert(dns.servers, v.server)
table.insert(dns.rules, {
action = "route",
@@ -1777,11 +1795,6 @@ function gen_config(var)
})
end
- table.insert(dns.servers, {
- type = "local",
- tag = "local"
- })
-
local direct_strategy = "prefer_ipv6"
if direct_dns_query_strategy == "UseIPv4" then
direct_strategy = "ipv4_only"
@@ -1836,6 +1849,20 @@ function gen_config(var)
end
end
+ if direct_dns_udp_server then
+ local nodes_domain = {}
+ local nodes_domain_text = sys.exec('uci show passwall2 | grep ".address=" | cut -d "\'" -f 2 | grep "[a-zA-Z]$" | sort -u')
+ string.gsub(nodes_domain_text, '[^' .. "\r\n" .. ']+', function(w)
+ table.insert(nodes_domain, w)
+ end)
+ if #nodes_domain > 0 then
+ table.insert(dns_domain_rules, 1, {
+ domain = nodes_domain,
+ outboundTag = "direct"
+ })
+ end
+ end
+
remote_strategy = "prefer_ipv6"
if remote_dns_query_strategy == "UseIPv4" then
remote_strategy = "ipv4_only"
@@ -1913,30 +1940,6 @@ function gen_config(var)
}
end
- if direct_dns_udp_server then
- local domain = {}
- local nodes_domain_text = sys.exec('uci show passwall2 | grep ".address=" | cut -d "\'" -f 2 | grep "[a-zA-Z]$" | sort -u')
- string.gsub(nodes_domain_text, '[^' .. "\r\n" .. ']+', function(w)
- table.insert(domain, w)
- end)
- if #domain > 0 then
- table.insert(dns_domain_rules, 1, {
- domain = domain,
- outboundTag = "direct"
- })
- end
-
- local server_port = tonumber(direct_dns_udp_port) or 53
-
- table.insert(dns.servers, {
- tag = "direct",
- type = "udp",
- server = direct_dns_udp_server,
- server_port = server_port,
- detour = "direct",
- })
- end
-
local default_dns_flag = "remote"
if node_id and redir_port then
local node = get_node_by_id(node_id)
diff --git a/luci-app-passwall2/luasrc/passwall2/util_xray.lua b/luci-app-passwall2/luasrc/passwall2/util_xray.lua
index b76714e8..7cc38948 100644
--- a/luci-app-passwall2/luasrc/passwall2/util_xray.lua
+++ b/luci-app-passwall2/luasrc/passwall2/util_xray.lua
@@ -8,7 +8,8 @@ local fs = api.fs
local CACHE_PATH = api.CACHE_PATH
local GLOBAL = {
- DNS_SERVER = {}
+ DNS_SERVER = {},
+ DNS_HOSTNAME = {}
}
local xray_version = api.get_app_version("xray")
@@ -442,6 +443,11 @@ function gen_outbound(flag, node, tag, proxy_table)
else
config_port = 443
end
+ if _a.hostname then
+ if api.datatypes.hostname(_a.hostname) then
+ GLOBAL.DNS_HOSTNAME[_a.hostname] = true
+ end
+ end
end
else
local server_address = node.domain_resolver_dns
@@ -461,7 +467,11 @@ function gen_outbound(flag, node, tag, proxy_table)
queryStrategy = node.domain_strategy or "UseIP",
address = config_address,
port = config_port,
- domains = {"full:" .. node.address}
+ domains = {"full:" .. node.address},
+ finalQuery = true,
+ disableCache = false,
+ serveStale = true,
+ serveExpiredTTL = 30,
}
end
@@ -1463,13 +1473,6 @@ function gen_config(var)
local remote_fakedns_tag = "dns-in-remote-fakedns"
local default_dns_tag = "dns-in-default"
- for i, v in pairs(GLOBAL.DNS_SERVER) do
- table.insert(dns_servers, {
- server = v,
- outboundTag = "direct"
- })
- end
-
dns = {
tag = "dns-global",
hosts = {},
@@ -1480,6 +1483,13 @@ function gen_config(var)
queryStrategy = "UseIP"
}
+ for i, v in pairs(GLOBAL.DNS_SERVER) do
+ table.insert(dns_servers, {
+ server = v,
+ outboundTag = "direct"
+ })
+ end
+
local _direct_dns = nil
if direct_dns_udp_server then
_direct_dns = {
@@ -1497,6 +1507,27 @@ function gen_config(var)
end
end
+ if next(GLOBAL.DNS_HOSTNAME) then
+ local hostname = {}
+ for line, _ in pairs(GLOBAL.DNS_HOSTNAME) do
+ table.insert(hostname, line)
+ end
+ local new_dns_server
+ if _direct_dns then
+ new_dns_server = api.clone(_direct_dns)
+ else
+ new_dns_server = {
+ address = "localhost"
+ }
+ end
+ new_dns_server.tag = "dns-in-bootstrap"
+ new_dns_server.domains = hostname
+ table.insert(dns_servers, #dns_servers - 1, {
+ outboundTag = "direct",
+ server = new_dns_server
+ })
+ end
+
if dns_listen_port then
local _remote_dns_proto = "tcp"
@@ -1604,9 +1635,13 @@ function gen_config(var)
end)
if #domain > 0 then
table.insert(dns.servers, 1, {
- tag = "local",
+ tag = "dns-in-vpslist",
address = "localhost",
- domains = domain
+ domains = domain,
+ finalQuery = true,
+ disableCache = false,
+ serveStale = true,
+ serveExpiredTTL = 30,
})
end
end
@@ -2121,11 +2156,15 @@ function gen_front_dns_config(var)
end)
if #node_domain > 0 then
table.insert(dns.servers, {
- tag = "direct",
+ tag = "dns-in-vpslist",
address = direct_dns_udp_server,
port = tonumber(direct_dns_udp_port) or 53,
queryStrategy = queryStrategy,
- domains = node_domain
+ domains = node_domain,
+ finalQuery = true,
+ disableCache = false,
+ serveStale = true,
+ serveExpiredTTL = 30,
})
end
end
diff --git a/luci-app-passwall2/po/fa/passwall2.po b/luci-app-passwall2/po/fa/passwall2.po
index 16d161f1..639220d8 100644
--- a/luci-app-passwall2/po/fa/passwall2.po
+++ b/luci-app-passwall2/po/fa/passwall2.po
@@ -1776,6 +1776,9 @@ msgstr "حل مشکل DNS دامنه"
msgid "If the node address is a domain name, this DNS will be used for resolution."
msgstr "اگر آدرس گره یک نام دامنه باشد، از این DNS برای حل مسئله استفاده خواهد شد."
+msgid "Supports only Xray or Sing-box node types."
+msgstr "فقط گرههای نوع Xray یا Sing-box پشتیبانی میشوند."
+
msgid "Chain Proxy"
msgstr "پروکسی زنجیرهای"
@@ -1792,9 +1795,6 @@ msgstr ""
"پروکسی زنجیرهای فقط با گرههای Xray یا Sing-box کار میکند.
"
"شما فقط میتوانید از گرههای دستی یا وارد شده به عنوان گرههای زنجیرهای استفاده کنید."
-msgid "Set the default domain resolution strategy for the sing-box node."
-msgstr "تنظیم استراتژی پیشفرض حل دامنه برای گره sing-box."
-
msgid "Prefer IPv4"
msgstr "ترجیح IPv4"
diff --git a/luci-app-passwall2/po/ru/passwall2.po b/luci-app-passwall2/po/ru/passwall2.po
index d72e63e4..6ccc3aab 100644
--- a/luci-app-passwall2/po/ru/passwall2.po
+++ b/luci-app-passwall2/po/ru/passwall2.po
@@ -1777,6 +1777,9 @@ msgstr "Разрешение DNS-запросов для домена"
msgid "If the node address is a domain name, this DNS will be used for resolution."
msgstr "Если адрес узла является доменным именем, для разрешения будет использоваться этот DNS-сервер."
+msgid "Supports only Xray or Sing-box node types."
+msgstr "Поддерживаются только узлы типа Xray или Sing-box."
+
msgid "Chain Proxy"
msgstr "Цепочка прокси"
@@ -1793,9 +1796,6 @@ msgstr ""
"Цепочка прокси работает только с серверами Xray или Sing-Box.
"
"В качестве звеньев цепочки можно использовать только серверы, добавленные вручную или импортированные."
-msgid "Set the default domain resolution strategy for the sing-box node."
-msgstr "Задать стратегию разрешения доменов по умолчанию для сервера Sing-Box."
-
msgid "Prefer IPv4"
msgstr "Предпочитать IPv4"
diff --git a/luci-app-passwall2/po/zh-cn/passwall2.po b/luci-app-passwall2/po/zh-cn/passwall2.po
index c00f9380..4305a01f 100644
--- a/luci-app-passwall2/po/zh-cn/passwall2.po
+++ b/luci-app-passwall2/po/zh-cn/passwall2.po
@@ -1768,6 +1768,9 @@ msgstr "域名 DNS 解析"
msgid "If the node address is a domain name, this DNS will be used for resolution."
msgstr "如果节点地址是域名,则将使用此 DNS 进行解析。"
+msgid "Supports only Xray or Sing-box node types."
+msgstr "仅支持 Xray 或 Sing-box 类型节点。"
+
msgid "Chain Proxy"
msgstr "链式代理"
@@ -1781,12 +1784,9 @@ msgid ""
"Chained proxy works only with Xray or Sing-box nodes.
"
"You can only use manual or imported nodes as chained nodes."
msgstr ""
-"链式代理仅支持 Xray 与 Sing-box 节点。
"
+"链式代理仅支持 Xray 或 Sing-box 节点。
"
"仅支持手动添加或导入的节点用作链式节点。"
-msgid "Set the default domain resolution strategy for the sing-box node."
-msgstr "为 sing-box 节点设置默认的域名解析策略。"
-
msgid "Prefer IPv4"
msgstr "IPv4 优先"
diff --git a/luci-app-passwall2/po/zh-tw/passwall2.po b/luci-app-passwall2/po/zh-tw/passwall2.po
index d3ca033e..65f3cc50 100644
--- a/luci-app-passwall2/po/zh-tw/passwall2.po
+++ b/luci-app-passwall2/po/zh-tw/passwall2.po
@@ -1768,6 +1768,9 @@ msgstr "域名 DNS 解析"
msgid "If the node address is a domain name, this DNS will be used for resolution."
msgstr "如果節點地址是域名,則將使用此 DNS 進行解析。"
+msgid "Supports only Xray or Sing-box node types."
+msgstr "僅支援 Xray 或 Sing-box 類型節點。"
+
msgid "Chain Proxy"
msgstr "鏈式代理"
@@ -1781,12 +1784,9 @@ msgid ""
"Chained proxy works only with Xray or Sing-box nodes.
"
"You can only use manual or imported nodes as chained nodes."
msgstr ""
-"鏈式代理仅支持 Xray 与 Sing-box 節點。
"
+"鏈式代理仅支持 Xray 或 Sing-box 節點。
"
"仅支持手動添加或導入的節點用作鏈式節點。"
-msgid "Set the default domain resolution strategy for the sing-box node."
-msgstr "為 sing-box 節點設置默認的域名解析策略。"
-
msgid "Prefer IPv4"
msgstr "IPv4 優先"
diff --git a/luci-app-passwall2/root/usr/share/passwall2/app.sh b/luci-app-passwall2/root/usr/share/passwall2/app.sh
index c2bfcb04..5a8e9128 100755
--- a/luci-app-passwall2/root/usr/share/passwall2/app.sh
+++ b/luci-app-passwall2/root/usr/share/passwall2/app.sh
@@ -134,16 +134,10 @@ run_xray() {
set_cache_var "node_${node}_direct_nftset6" "${direct_nftset6}"
}
}
- json_add_string "direct_dns_udp_port" "${DIRECT_DNS_UDP_PORT}"
- json_add_string "direct_dns_udp_server" "${DIRECT_DNS_UDP_SERVER}"
- json_add_string "direct_dns_query_strategy" "${direct_dns_query_strategy}"
[ "$remote_fakedns" = "1" ] && {
json_add_string "remote_dns_fake" "1"
json_add_string "remote_dns_fake_strategy" "${remote_dns_query_strategy}"
}
- local _json1_arg="$(json_dump)"
-
- json_init
case "$remote_dns_protocol" in
udp)
local _dns=$(get_first_dns remote_dns_udp_server 53 | sed 's/#/:/g')
@@ -178,20 +172,10 @@ run_xray() {
[ -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}"
- local _json2_arg="$(json_dump)"
-
- local _json2_keys key
- json_load "${_json2_arg}"
- json_get_keys _json2_keys
- for key in ${_json2_keys}; do
- json_get_var "_json2_$key" "$key"
- done
- json_load "${_json1_arg}"
- for key in ${_json2_keys}; do
- eval "local _v=\$_json2_$key"
- json_add_string "$key" "$_v"
- done
}
+ json_add_string "direct_dns_udp_port" "${DIRECT_DNS_UDP_PORT}"
+ json_add_string "direct_dns_udp_server" "${DIRECT_DNS_UDP_SERVER}"
+ json_add_string "direct_dns_query_strategy" "${direct_dns_query_strategy}"
[ -n "${redir_port}" ] && {
json_add_string "redir_port" "${redir_port}"
@@ -209,7 +193,7 @@ run_xray() {
$XRAY_BIN run -test -c "$config_file" > $test_log_file; local status=$?
if [ "${status}" == 0 ]; then
- ln_run "$XRAY_BIN" xray $log_file run -c "$config_file"
+ ln_run ${QUEUE_RUN} "$XRAY_BIN" xray $log_file run -c "$config_file"
else
_error_log_file=$test_log_file
return ${status}
@@ -289,9 +273,6 @@ run_singbox() {
set_cache_var "node_${node}_direct_nftset6" "${direct_nftset6}"
}
}
- json_add_string "direct_dns_udp_port" "${DIRECT_DNS_UDP_PORT}"
- json_add_string "direct_dns_udp_server" "${DIRECT_DNS_UDP_SERVER}"
- json_add_string "direct_dns_query_strategy" "${direct_dns_query_strategy}"
case "$remote_dns_protocol" in
udp|\
@@ -339,6 +320,9 @@ run_singbox() {
[ -n "$dns_cache" ] && json_add_string "dns_cache" "${dns_cache}"
[ "$remote_fakedns" = "1" ] && json_add_string "remote_dns_fake" "1"
}
+ json_add_string "direct_dns_udp_port" "${DIRECT_DNS_UDP_PORT}"
+ json_add_string "direct_dns_udp_server" "${DIRECT_DNS_UDP_SERVER}"
+ json_add_string "direct_dns_query_strategy" "${direct_dns_query_strategy}"
[ -n "${redir_port}" ] && {
json_add_string "redir_port" "${redir_port}"
@@ -356,7 +340,7 @@ run_singbox() {
$SINGBOX_BIN check -c "$config_file" > $test_log_file 2>&1; local status=$?
if [ "${status}" == 0 ]; then
- ln_run "$SINGBOX_BIN" "sing-box" "${log_file}" run -c "$config_file"
+ ln_run ${QUEUE_RUN} "$SINGBOX_BIN" "sing-box" "${log_file}" run -c "$config_file"
else
_error_log_file=$test_log_file
return ${status}
@@ -435,9 +419,12 @@ run_socks() {
json_add_string "flag" "SOCKS_${flag}"
json_add_string "local_socks_address" "${bind}"
json_add_string "local_socks_port" "${socks_port}"
+ json_add_string "direct_dns_udp_port" "${DIRECT_DNS_UDP_PORT}"
+ json_add_string "direct_dns_udp_server" "${DIRECT_DNS_UDP_SERVER}"
+ json_add_string "direct_dns_query_strategy" "${DIRECT_DNS_QUERY_STRATEGY}"
local _json_arg="$(json_dump)"
lua $UTIL_SINGBOX gen_config "${_json_arg}" > $config_file
- [ -z "$no_run" ] && ln_run "$SINGBOX_BIN" "sing-box" /dev/null run -c "$config_file"
+ [ -z "$no_run" ] && ln_run ${QUEUE_RUN} "$SINGBOX_BIN" "sing-box" /dev/null run -c "$config_file"
;;
xray)
[ "$http_port" != "0" ] && {
@@ -454,9 +441,12 @@ run_socks() {
json_add_string "flag" "SOCKS_${flag}"
json_add_string "local_socks_address" "${bind}"
json_add_string "local_socks_port" "${socks_port}"
+ json_add_string "direct_dns_udp_port" "${DIRECT_DNS_UDP_PORT}"
+ json_add_string "direct_dns_udp_server" "${DIRECT_DNS_UDP_SERVER}"
+ json_add_string "direct_dns_query_strategy" "${DIRECT_DNS_QUERY_STRATEGY}"
local _json_arg="$(json_dump)"
lua $UTIL_XRAY gen_config "${_json_arg}" > $config_file
- [ -z "$no_run" ] && ln_run "$XRAY_BIN" "xray" $log_file run -c "$config_file"
+ [ -z "$no_run" ] && ln_run ${QUEUE_RUN} "$XRAY_BIN" "xray" $log_file run -c "$config_file"
;;
naiveproxy)
json_add_string "local_addr" "${bind}"
@@ -464,14 +454,14 @@ run_socks() {
json_add_string "run_type" "socks"
local _json_arg="$(json_dump)"
lua $UTIL_NAIVE gen_config "${_json_arg}" > $config_file
- [ -z "$no_run" ] && ln_run "$(first_type naive)" naive $log_file "$config_file"
+ [ -z "$no_run" ] && ln_run ${QUEUE_RUN} "$(first_type naive)" naive $log_file "$config_file"
;;
ssr)
json_add_string "local_addr" "${bind}"
json_add_string "local_port" "${socks_port}"
local _json_arg="$(json_dump)"
lua $UTIL_SS gen_config "${_json_arg}" > $config_file
- [ -z "$no_run" ] && ln_run "$(first_type ssr-local)" "ssr-local" $log_file -c "$config_file" -v -u
+ [ -z "$no_run" ] && ln_run ${QUEUE_RUN} "$(first_type ssr-local)" "ssr-local" $log_file -c "$config_file" -v -u
;;
ss)
json_add_string "local_addr" "${bind}"
@@ -483,7 +473,7 @@ run_socks() {
}
local _json_arg="$(json_dump)"
lua $UTIL_SS gen_config "${_json_arg}" > $config_file
- [ -z "$no_run" ] && ln_run "$(first_type ss-local)" "ss-local" $log_file -c "$config_file" -v
+ [ -z "$no_run" ] && ln_run ${QUEUE_RUN} "$(first_type ss-local)" "ss-local" $log_file -c "$config_file" -v
;;
ss-rust)
json_add_string "local_socks_address" "${bind}"
@@ -500,7 +490,7 @@ run_socks() {
}
local _json_arg="$(json_dump)"
lua $UTIL_SS gen_config "${_json_arg}" > $config_file
- [ -z "$no_run" ] && ln_run "$(first_type sslocal)" "sslocal" $log_file -c "$config_file" -v
+ [ -z "$no_run" ] && ln_run ${QUEUE_RUN} "$(first_type sslocal)" "sslocal" $log_file -c "$config_file" -v
;;
hysteria2)
json_add_string "local_socks_address" "${bind}"
@@ -513,14 +503,14 @@ run_socks() {
}
local _json_arg="$(json_dump)"
lua $UTIL_HYSTERIA2 gen_config "${_json_arg}" > $config_file
- [ -z "$no_run" ] && ln_run "$(first_type $(config_t_get global_app hysteria_file))" "hysteria" $log_file -c "$config_file" client
+ [ -z "$no_run" ] && ln_run ${QUEUE_RUN} "$(first_type $(config_t_get global_app hysteria_file))" "hysteria" $log_file -c "$config_file" client
;;
tuic)
json_add_string "local_addr" "${bind}"
json_add_string "local_port" "${socks_port}"
local _json_arg="$(json_dump)"
lua $UTIL_TUIC gen_config "${_json_arg}" > $config_file
- [ -z "$no_run" ] && ln_run "$(first_type tuic-client)" "tuic-client" $log_file -c "$config_file"
+ [ -z "$no_run" ] && ln_run ${QUEUE_RUN} "$(first_type tuic-client)" "tuic-client" $log_file -c "$config_file"
;;
esac
@@ -545,7 +535,7 @@ run_socks() {
fi
[ -n "${bin}" ] && [ -n "${util}" ] && {
lua ${util} gen_proto_config "${_json_arg}" > ${http_config_file}
- [ -z "$no_run" ] && ln_run "${bin}" ${type} /dev/null run -c ${http_config_file}
+ [ -z "$no_run" ] && ln_run ${QUEUE_RUN} "${bin}" ${type} /dev/null run -c ${http_config_file}
}
unset bin util
}
@@ -699,16 +689,16 @@ run_front_dns() {
}
local _json_arg="$(json_dump)"
- local preferred_core=""
- [ -n "${XRAY_BIN}" ] && preferred_core="xray"
- [ -n "${SINGBOX_BIN}" ] && preferred_core="sing-box"
+ local prefer_core=""
+ [ -n "${XRAY_BIN}" ] && prefer_core="xray"
+ [ -n "${SINGBOX_BIN}" ] && prefer_core="sing-box"
- if [ "${preferred_core}" = "xray" ]; then
+ if [ "${prefer_core}" = "xray" ]; then
lua $UTIL_XRAY gen_front_dns_config "${_json_arg}" > $config_file
- ln_run "$XRAY_BIN" "xray" "${log_file}" run -c "$config_file"
- elif [ "${preferred_core}" = "sing-box" ]; then
+ ln_run 0 "$XRAY_BIN" "xray" "${log_file}" run -c "$config_file"
+ elif [ "${prefer_core}" = "sing-box" ]; then
lua $UTIL_SINGBOX gen_front_dns_config "${_json_arg}" > $config_file
- ln_run "$SINGBOX_BIN" "sing-box" "${log_file}" run -c "$config_file"
+ ln_run 0 "$SINGBOX_BIN" "sing-box" "${log_file}" run -c "$config_file"
else
return 1
fi
@@ -743,7 +733,7 @@ run_global_dnsmasq() {
json_add_string "DNSMASQ_CONF" "${DIRECT_DNSMASQ_CONF}"
json_add_string "TMP_DNSMASQ_PATH" "${DIRECT_DNSMASQ_CONF_PATH}"
lua $APP_PATH/helper_dnsmasq.lua copy_instance "$(json_dump)"
- ln_run "$(first_type dnsmasq)" "dnsmasq_direct" "/dev/null" -C ${DIRECT_DNSMASQ_CONF} -x ${GLOBAL_ACL_PATH}/direct_dnsmasq.pid
+ ln_run 0 "$(first_type dnsmasq)" "dnsmasq_direct" "/dev/null" -C ${DIRECT_DNSMASQ_CONF} -x ${GLOBAL_ACL_PATH}/direct_dnsmasq.pid
set_cache_var "DIRECT_DNSMASQ_PORT" "${DIRECT_DNSMASQ_PORT}"
}
@@ -769,7 +759,7 @@ run_global_dnsmasq() {
else
#Run a copy dnsmasq instance, DNS hijack for that need proxy devices.
GLOBAL_DNSMASQ_PORT=$(get_new_port 11400)
- run_copy_dnsmasq flag="default" listen_port=$GLOBAL_DNSMASQ_PORT tun_dns="${DNSMASQ_TUN_DNS}"
+ run_copy_dnsmasq flag="default" listen_port=$GLOBAL_DNSMASQ_PORT local_dns="${DNSMASQ_LOCAL_DNS}" tun_dns="${DNSMASQ_TUN_DNS}" default_dns="${DNSMASQ_DEFAULT_DNS}"
DNS_REDIRECT_PORT=${GLOBAL_DNSMASQ_PORT}
#dhcp.leases to hosts
$APP_PATH/lease2hosts.sh > /dev/null 2>&1 &
@@ -944,11 +934,11 @@ start_haproxy() {
haproxy_path=$TMP_PATH/haproxy
haproxy_conf="config.cfg"
lua $APP_PATH/haproxy.lua -path ${haproxy_path} -conf ${haproxy_conf} -dns ${LOCAL_DNS:-${AUTO_DNS}}
- ln_run "$(first_type haproxy)" haproxy "/dev/null" -f "${haproxy_path}/${haproxy_conf}"
+ ln_run ${QUEUE_RUN} "$(first_type haproxy)" haproxy "/dev/null" -f "${haproxy_path}/${haproxy_conf}"
}
run_copy_dnsmasq() {
- local flag listen_port tun_dns
+ local flag listen_port local_dns tun_dns default_dns
eval_set_val $@
local dnsmasq_conf=$TMP_ACL_PATH/$flag/dnsmasq.conf
local dnsmasq_conf_path=$TMP_ACL_PATH/$flag/dnsmasq.d
@@ -963,14 +953,14 @@ run_copy_dnsmasq() {
json_add_string "FLAG" "${flag}"
json_add_string "TMP_DNSMASQ_PATH" "${dnsmasq_conf_path}"
json_add_string "DNSMASQ_CONF_FILE" "${dnsmasq_conf}"
- json_add_string "DEFAULT_DNS" "${AUTO_DNS}"
- json_add_string "LOCAL_DNS" "${LOCAL_DNS:-${AUTO_DNS}}"
+ json_add_string "DEFAULT_DNS" "${default_dns}"
+ json_add_string "LOCAL_DNS" "${local_dns}"
json_add_string "TUN_DNS" "${tun_dns}"
json_add_string "NFTFLAG" "${nftflag:-0}"
json_add_string "NO_LOGIC_LOG" "${NO_LOGIC_LOG:-0}"
lua $APP_PATH/helper_dnsmasq.lua add_rule "$(json_dump)"
- ln_run "$(first_type dnsmasq)" "dnsmasq_${flag}" "/dev/null" -C $dnsmasq_conf -x $TMP_ACL_PATH/$flag/dnsmasq.pid
+ ln_run 0 "$(first_type dnsmasq)" "dnsmasq_${flag}" "/dev/null" -C $dnsmasq_conf -x $TMP_ACL_PATH/$flag/dnsmasq.pid
set_cache_var "ACL_${flag}_dns_port" "${listen_port}"
}
@@ -1011,7 +1001,7 @@ run_ipset_chinadns_ng() {
group-upstream ${server_dns}
group-ipset ${vps_set_names}
EOF
- ln_run "$(first_type chinadns-ng)" "chinadns-ng" "/dev/null" -C $config_file -v
+ ln_run 0 "$(first_type chinadns-ng)" "chinadns-ng" "/dev/null" -C $config_file -v
}
run_ipset_dnsmasq() {
@@ -1030,7 +1020,7 @@ run_ipset_dnsmasq() {
done
[ -n "${ipset}" ] && echo "ipset=${ipset}" >> $config_file
[ -n "${nftset}" ] && echo "nftset=${nftset}" >> $config_file
- ln_run "$(first_type dnsmasq)" "dnsmasq" "/dev/null" -C $config_file
+ ln_run 0 "$(first_type dnsmasq)" "dnsmasq" "/dev/null" -C $config_file
}
acl_app() {
@@ -1154,7 +1144,7 @@ acl_app() {
fi
fi
dnsmasq_port=$(get_new_port $(expr $dnsmasq_port + 1))
- run_copy_dnsmasq flag="$sid" listen_port=$dnsmasq_port tun_dns="127.0.0.1#${dns_port}"
+ run_copy_dnsmasq flag="$sid" listen_port=$dnsmasq_port local_dns="${LOCAL_DNS:-${AUTO_DNS}}" tun_dns="127.0.0.1#${dns_port}" default_dns="${AUTO_DNS}"
#dhcp.leases to hostsMore actions
$APP_PATH/lease2hosts.sh > /dev/null 2>&1 &
@@ -1177,7 +1167,6 @@ start() {
stop
}
mkdir -p /tmp/etc /tmp/log $TMP_PATH $TMP_BIN_PATH $TMP_SCRIPT_FUNC_PATH $TMP_ROUTE_PATH $TMP_ACL_PATH $TMP_PATH2
- get_config
export V2RAY_LOCATION_ASSET=$(config_t_get global_rules v2ray_location_asset "/usr/share/v2ray/")
export XRAY_LOCATION_ASSET=$V2RAY_LOCATION_ASSET
export ENABLE_DEPRECATED_GEOSITE=true
@@ -1217,6 +1206,7 @@ start() {
sysctl -w net.bridge.bridge-nf-call-ip6tables=0 >/dev/null 2>&1
}
fi
+ run_process_queue
start_crontab
log_i18n 0 "Running complete!"
echolog "\n"
@@ -1346,15 +1336,21 @@ get_config() {
fi
set_cache_var GLOBAL_DNSMASQ_CONF ${DNSMASQ_CONF_DIR}/dnsmasq-${CONFIG}.conf
set_cache_var GLOBAL_DNSMASQ_CONF_PATH ${GLOBAL_ACL_PATH}/dnsmasq.d
+
+ QUEUE_RUN=1
}
+get_config
+
arg1=$1
shift
case $arg1 in
run_socks)
+ QUEUE_RUN=0
run_socks $@
;;
socks_node_switch)
+ QUEUE_RUN=0
socks_node_switch $@
;;
start)
diff --git a/luci-app-passwall2/root/usr/share/passwall2/monitor.sh b/luci-app-passwall2/root/usr/share/passwall2/monitor.sh
index e8b85cf4..80e61cae 100755
--- a/luci-app-passwall2/root/usr/share/passwall2/monitor.sh
+++ b/luci-app-passwall2/root/usr/share/passwall2/monitor.sh
@@ -18,7 +18,6 @@ while [ "$ENABLED" -eq 1 ]; do
for filename in $(ls ${TMP_SCRIPT_FUNC_PATH} | grep -v "^_"); do
cmd=$(cat ${TMP_SCRIPT_FUNC_PATH}/${filename})
cmd_check=$(echo $cmd | awk -F '>' '{print $1}')
- [ -n "$(echo $cmd_check | grep "dns2socks")" ] && cmd_check=$(echo $cmd_check | sed "s#:# #g")
icount=$(pgrep -f "$(echo $cmd_check)" | wc -l)
if [ $icount = 0 ]; then
#echo "${cmd} crashed, restarting." >> /tmp/log/passwall2.log
diff --git a/luci-app-passwall2/root/usr/share/passwall2/socks_auto_switch.sh b/luci-app-passwall2/root/usr/share/passwall2/socks_auto_switch.sh
index aec9a825..434d9606 100755
--- a/luci-app-passwall2/root/usr/share/passwall2/socks_auto_switch.sh
+++ b/luci-app-passwall2/root/usr/share/passwall2/socks_auto_switch.sh
@@ -49,9 +49,9 @@ test_node() {
local _type=$(echo $(config_n_get ${node_id} type) | tr 'A-Z' 'a-z')
[ -n "${_type}" ] && {
local _tmp_port=$(get_new_port 48800 tcp,udp)
- $APP_FILE run_socks flag="test_node_${node_id}" node=${node_id} bind=127.0.0.1 socks_port=${_tmp_port} config_file=test_node_${node_id}.json
+ NO_REC_PROCESS=1 $APP_FILE run_socks flag="test_node_${node_id}" node=${node_id} bind=127.0.0.1 socks_port=${_tmp_port} config_file=test_node_${node_id}.json
+ sleep 2s
local curlx="socks5h://127.0.0.1:${_tmp_port}"
- sleep 1s
local _proxy_status=$(test_url "${probe_url}" ${retry_num} ${connect_timeout} "-x $curlx")
# Kill the SS plugin process
local pid_file="/tmp/etc/${CONFIG}/test_node_${node_id}_plugin.pid"
diff --git a/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua b/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua
index 7a2ae59e..41667309 100755
--- a/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua
+++ b/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua
@@ -42,8 +42,7 @@ local core_has = {
["xray"] = has_xray, ["sing-box"] = has_singbox, ["shadowsocks-libev"] = has_ss,["shadowsocks-rust"] = has_ss_rust,
["hysteria2"] = has_hysteria2
}
-local domain_strategy_default = uci:get(appname, "@global_subscribe[0]", "domain_strategy") or ""
-local domain_strategy_node = ""
+local domain_resolver, domain_resolver_dns, domain_resolver_dns_https, domain_strategy
local preproxy_node_group, to_node_group, chain_node_type = "", "", ""
-- Determine whether to filter node keywords
local filter_keyword_mode_default = uci:get(appname, "@global_subscribe[0]", "filter_keyword_mode") or "0"
@@ -1842,9 +1841,22 @@ local function update_node(manual)
if kkk ~= "group" or vvv ~= "default" then
uci:set(appname, cfgid, kkk, vvv)
end
- -- Sing-Box Domain Strategy
- if kkk == "type" and vvv == "sing-box" then
- uci:set(appname, cfgid, "domain_strategy", domain_strategy_node)
+ -- Sing-Box Node Domain resolver
+ if kkk == "type" and (vvv == "Xray" or vvv == "sing-box") then
+ if domain_resolver then
+ uci:set(appname, cfgid, "domain_resolver", domain_resolver)
+ if domain_resolver_dns then
+ uci:set(appname, cfgid, "domain_resolver_dns", domain_resolver_dns)
+ elseif domain_resolver_dns_https then
+ uci:set(appname, cfgid, "domain_resolver_dns_https", domain_resolver_dns_https)
+ end
+ end
+ if domain_strategy then
+ if vvv == "sing-box" then
+ domain_strategy = (domain_strategy == "UseIPv4" and "ipv4_only") or (domain_strategy == "UseIPv6" and "ipv6_only") or domain_strategy
+ end
+ uci:set(appname, cfgid, "domain_strategy", domain_strategy)
+ end
end
-- Subscription Group Chain Agent
if chain_node_type ~= "" and kkk == "type" and (vvv == "Xray" or vvv == "sing-box") then
@@ -2059,12 +2071,11 @@ local execute = function()
if hysteria2_type ~= "global" and core_has[hysteria2_type] then
hysteria2_type_default = hysteria2_type
end
- local domain_strategy = value.domain_strategy or "global"
- if domain_strategy ~= "global" then
- domain_strategy_node = domain_strategy
- else
- domain_strategy_node = domain_strategy_default
- end
+
+ domain_resolver = value.domain_resolver
+ domain_resolver_dns = value.domain_resolver_dns
+ domain_resolver_dns_https = value.domain_resolver_dns_https
+ domain_strategy = (value.domain_strategy == "UseIPv4" or value.domain_strategy == "UseIPv6") and value.domain_strategy or nil
-- Subscription Group Chain Agent
local function valid_chain_node(node)
diff --git a/luci-app-passwall2/root/usr/share/passwall2/test.sh b/luci-app-passwall2/root/usr/share/passwall2/test.sh
index a3fd1687..f83f4a24 100755
--- a/luci-app-passwall2/root/usr/share/passwall2/test.sh
+++ b/luci-app-passwall2/root/usr/share/passwall2/test.sh
@@ -47,9 +47,9 @@ url_test_node() {
local _type=$(echo $(config_n_get ${node_id} type) | tr 'A-Z' 'a-z')
[ -n "${_type}" ] && {
local _tmp_port=$(get_new_port 48900 tcp,udp)
- /usr/share/${CONFIG}/app.sh run_socks flag="url_test_${node_id}" node=${node_id} bind=127.0.0.1 socks_port=${_tmp_port} config_file=url_test_${node_id}.json
+ NO_REC_PROCESS=1 /usr/share/${CONFIG}/app.sh run_socks flag="url_test_${node_id}" node=${node_id} bind=127.0.0.1 socks_port=${_tmp_port} config_file=url_test_${node_id}.json
+ sleep 2s
local curlx="socks5h://127.0.0.1:${_tmp_port}"
- sleep 1s
local url=$(config_t_get global_other url_test_url https://www.google.com/generate_204)
result=$(curl --connect-timeout 3 -o /dev/null -I -skL -w "%{http_code}:%{time_starttransfer}" -x $curlx "${url}")
pgrep -af "url_test_${node_id}" | awk '! /test\.sh/{print $1}' | xargs kill -9 >/dev/null 2>&1
diff --git a/luci-app-passwall2/root/usr/share/passwall2/utils.sh b/luci-app-passwall2/root/usr/share/passwall2/utils.sh
index 77e4facf..75762a7f 100755
--- a/luci-app-passwall2/root/usr/share/passwall2/utils.sh
+++ b/luci-app-passwall2/root/usr/share/passwall2/utils.sh
@@ -13,6 +13,7 @@ TMP_BIN_PATH=${TMP_PATH}/bin
TMP_IFACE_PATH=${TMP_PATH}/iface
TMP_ROUTE_PATH=${TMP_PATH}/route
TMP_SCRIPT_FUNC_PATH=${TMP_PATH}/script_func
+TMP_PROCESS_LIST_PATH=${TMP_PATH}/process_list
. /lib/functions/network.sh
@@ -69,6 +70,7 @@ set_cache_var() {
shift 1
local val="$@"
[ -n "${key}" ] && [ -n "${val}" ] && {
+ [ ! -d $TMP_PATH ] && mkdir -p $TMP_PATH
sed -i "/${key}=/d" $TMP_PATH/var >/dev/null 2>&1
echo "${key}=\"${val}\"" >> $TMP_PATH/var
eval ${key}=\"${val}\"
@@ -372,11 +374,12 @@ delete_ip2route() {
}
ln_run() {
- local file_func=${1}
- local ln_name=${2}
- local output=${3}
+ local queue_run=${1}
+ local file_func=${2}
+ local ln_name=${3}
+ local output=${4}
+ shift 4;
- shift 3;
if [ "${file_func%%/*}" != "${file_func}" ]; then
[ ! -L "${file_func}" ] && {
ln -s "${file_func}" "${TMP_BIN_PATH}/${ln_name}" >/dev/null 2>&1
@@ -386,16 +389,37 @@ ln_run() {
fi
#echo "${file_func} $*" >&2
[ -n "${file_func}" ] || log 1 "$(i18n "%s not found, unable to start..." "${ln_name}")"
+
+ [ "${queue_run}" == "1" ] && {
+ mkdir -p $TMP_PROCESS_LIST_PATH
+ process_count=$(ls $TMP_PROCESS_LIST_PATH | grep -v "^_" | wc -l)
+ process_count=$((process_count + 1))
+ echo "${file_func:-log 1 "${ln_name}"} $@ >${output}" > $TMP_PROCESS_LIST_PATH/$process_count
+ return
+ }
+
${file_func:-log 1 "${ln_name}"} "$@" >${output} 2>&1 &
- local pid=${!}
- #sleep 1s
- #kill -0 ${pid} 2>/dev/null
- #local status_code=${?}
+ [ -n "$NO_REC_PROCESS" ] && return
+
process_count=$(ls $TMP_SCRIPT_FUNC_PATH | grep -v "^_" | wc -l)
process_count=$((process_count + 1))
echo "${file_func:-log 1 "${ln_name}"} $@ >${output}" > $TMP_SCRIPT_FUNC_PATH/$process_count
- #return ${status_code}
+}
+
+run_process_queue() {
+ [ -d ${TMP_PROCESS_LIST_PATH} ] && {
+ for filename in $(ls ${TMP_PROCESS_LIST_PATH}); do
+ cmd=$(cat ${TMP_PROCESS_LIST_PATH}/${filename})
+ cmd_check=$(echo $cmd | awk -F '>' '{print $1}')
+ icount=$(pgrep -f "$(echo $cmd_check)" | wc -l)
+ if [ $icount = 0 ]; then
+ eval $(echo "nohup ${cmd} 2>&1 &") >/dev/null 2>&1 &
+ fi
+ rm -rf ${TMP_PROCESS_LIST_PATH}/${filename}
+ done
+ }
+ rm -rf ${TMP_PROCESS_LIST_PATH}
}
kill_all() {