🍕 Sync 2025-11-10 00:09:51
This commit is contained in:
@@ -20,6 +20,7 @@ local port_validate = function(self, value, t)
|
||||
end
|
||||
|
||||
local nodes_table = {}
|
||||
local shunt_list = {}
|
||||
for k, e in ipairs(api.get_valid_nodes()) do
|
||||
nodes_table[#nodes_table + 1] = e
|
||||
end
|
||||
@@ -200,6 +201,9 @@ o:depends({ _tcp_node_bool = "1" })
|
||||
for k, v in pairs(nodes_table) do
|
||||
s.fields["tcp_node"]:value(v.id, v["remark"])
|
||||
s.fields["udp_node"]:value(v.id, v["remark"])
|
||||
if v.protocol and v.protocol == "_shunt" then
|
||||
shunt_list[#shunt_list + 1] = v
|
||||
end
|
||||
end
|
||||
|
||||
o = s:option(DummyValue, "_udp_node_bool", "")
|
||||
@@ -311,11 +315,7 @@ o.default = "0"
|
||||
o:depends({ _tcp_node_bool = "1" })
|
||||
|
||||
---- DNS Forward Mode
|
||||
o = s:option(ListValue, "dns_mode", translate("Filter Mode"),
|
||||
"<font color='red'>" .. translate(
|
||||
"If the node uses Xray/Sing-Box shunt, select the matching filter mode (Xray/Sing-Box).") ..
|
||||
"</font>")
|
||||
o:depends({ _tcp_node_bool = "1" })
|
||||
o = s:option(ListValue, "dns_mode", translate("Filter Mode"))
|
||||
if api.is_finded("dns2socks") then
|
||||
o:value("dns2socks", "dns2socks")
|
||||
end
|
||||
@@ -325,6 +325,19 @@ end
|
||||
if has_xray then
|
||||
o:value("xray", "Xray")
|
||||
end
|
||||
o.remove = function(self, section)
|
||||
local f = s.fields["tcp_node"]
|
||||
local id_val = f and f:formvalue(section) or ""
|
||||
if id_val == "" then
|
||||
return m:del(section, self.option)
|
||||
end
|
||||
for k, v in pairs(shunt_list) do
|
||||
if v.id == id_val then
|
||||
local new_val = (v.type == "Xray") and "xray" or "sing-box"
|
||||
return m:set(section, self.option, new_val)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
o = s:option(ListValue, "xray_dns_mode", translate("Request protocol"))
|
||||
o:value("tcp", "TCP")
|
||||
@@ -437,4 +450,21 @@ o:value("direct", translate("Direct DNS"))
|
||||
o.description = desc .. "</ul>"
|
||||
o:depends({dns_shunt = "dnsmasq", tcp_proxy_mode = "proxy", chn_list = "direct"})
|
||||
|
||||
for k, v in pairs(nodes_table) do
|
||||
if v.protocol and v.protocol ~= "_shunt" then
|
||||
s.fields["dns_mode"]:depends({ _tcp_node_bool = "1", tcp_node = v.id })
|
||||
end
|
||||
end
|
||||
for k, v in pairs(shunt_list) do
|
||||
if v.type == "Xray" and has_xray then
|
||||
s.fields["xray_dns_mode"]:depends({ _tcp_node_bool = "1", tcp_node = v.id })
|
||||
end
|
||||
if v.type == "sing-box" and has_singbox then
|
||||
s.fields["singbox_dns_mode"]:depends({ _tcp_node_bool = "1", tcp_node = v.id })
|
||||
end
|
||||
if has_xray or has_singbox then
|
||||
s.fields["remote_dns_client_ip"]:depends({ tcp_node = v.id })
|
||||
end
|
||||
end
|
||||
|
||||
return m
|
||||
|
||||
@@ -321,11 +321,37 @@ o:depends("direct_dns_mode", "tcp")
|
||||
o = s:taboption("DNS", Flag, "filter_proxy_ipv6", translate("Filter Proxy Host IPv6"), translate("Experimental feature."))
|
||||
o.default = "0"
|
||||
|
||||
-- TCP分流时dns过滤模式保存逻辑
|
||||
function dns_mode_save(section)
|
||||
for k, v in pairs(shunt_list) do
|
||||
local f = s.fields[v.id .. "-type"]
|
||||
if f then
|
||||
local type_val = f:formvalue(section)
|
||||
if type_val and (type_val == "Xray" or type_val == "sing-box") then
|
||||
local dns_shunt_val = s.fields["dns_shunt"]:formvalue(section)
|
||||
local dns_mode_val = (dns_shunt_val ~= "smartdns") and "dns_mode" or "smartdns_dns_mode"
|
||||
local current_val = m:get(section, dns_mode_val) or ""
|
||||
local new_val = (type_val == "Xray") and "xray" or "sing-box"
|
||||
|
||||
if current_val ~= new_val then
|
||||
m:set(section, dns_mode_val, new_val)
|
||||
m:del(section, (dns_mode_val == "dns_mode") and "smartdns_dns_mode" or "dns_mode")
|
||||
end
|
||||
|
||||
local dns_field = s.fields[type_val == "Xray" and "xray_dns_mode" or "singbox_dns_mode"]
|
||||
local v2ray_dns_mode = dns_field and dns_field:formvalue(section)
|
||||
if v2ray_dns_mode and m:get(section, "v2ray_dns_mode") ~= v2ray_dns_mode then
|
||||
m:set(section, "v2ray_dns_mode", v2ray_dns_mode)
|
||||
end
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---- DNS Forward Mode
|
||||
o = s:taboption("DNS", ListValue, "dns_mode", translate("Filter Mode"),
|
||||
"<font color='red'>" .. translate(
|
||||
"If the node uses Xray/Sing-Box shunt, select the matching filter mode (Xray/Sing-Box).") ..
|
||||
"</font>")
|
||||
o = s:taboption("DNS", ListValue, "dns_mode", translate("Filter Mode"))
|
||||
o:value("udp", translatef("Requery DNS By %s", "UDP"))
|
||||
o:value("tcp", translatef("Requery DNS By %s", "TCP"))
|
||||
if api.is_finded("dns2socks") then
|
||||
@@ -337,16 +363,19 @@ end
|
||||
if has_xray then
|
||||
o:value("xray", "Xray")
|
||||
end
|
||||
if api.is_finded("smartdns") then
|
||||
o:depends({ dns_shunt = "smartdns", ['!reverse'] = true })
|
||||
o:depends({ dns_shunt = "chinadns-ng", tcp_node = "" })
|
||||
o:depends({ dns_shunt = "dnsmasq", tcp_node = "" })
|
||||
o.remove = function(self, section)
|
||||
local f = s.fields["smartdns_dns_mode"]
|
||||
if f and f:formvalue(section) then
|
||||
return m:del(section, self.option)
|
||||
end
|
||||
dns_mode_save(section)
|
||||
end
|
||||
|
||||
---- SmartDNS Forward Mode
|
||||
if api.is_finded("smartdns") then
|
||||
o = s:taboption("DNS", ListValue, "smartdns_dns_mode", translate("Filter Mode"),
|
||||
"<font color='red'>" .. translate(
|
||||
"If the node uses Xray/Sing-Box shunt, select the matching filter mode (Xray/Sing-Box).") ..
|
||||
"</font>")
|
||||
o = s:taboption("DNS", ListValue, "smartdns_dns_mode", translate("Filter Mode"))
|
||||
o:value("socks", "Socks")
|
||||
if has_singbox then
|
||||
o:value("sing-box", "Sing-Box")
|
||||
@@ -354,7 +383,14 @@ if api.is_finded("smartdns") then
|
||||
if has_xray then
|
||||
o:value("xray", "Xray")
|
||||
end
|
||||
o:depends({ dns_shunt = "smartdns" })
|
||||
o:depends({ dns_shunt = "smartdns", tcp_node = "" })
|
||||
o.remove = function(self, section)
|
||||
local f = s.fields["dns_mode"]
|
||||
if f and f:formvalue(section) then
|
||||
return m:del(section, self.option)
|
||||
end
|
||||
dns_mode_save(section)
|
||||
end
|
||||
|
||||
o = s:taboption("DNS", DynamicList, "smartdns_remote_dns", translate("Remote DNS"))
|
||||
o:value("tcp://1.1.1.1")
|
||||
@@ -399,7 +435,7 @@ if api.is_finded("smartdns") then
|
||||
end
|
||||
end
|
||||
|
||||
o = s:taboption("DNS", ListValue, "xray_dns_mode", translate("Request protocol"))
|
||||
o = s:taboption("DNS", ListValue, "xray_dns_mode", translate("Remote DNS") .. " " .. translate("Request protocol"))
|
||||
o:value("tcp", "TCP")
|
||||
o:value("tcp+doh", "TCP + DoH (" .. translate("A/AAAA type") .. ")")
|
||||
o:depends("dns_mode", "xray")
|
||||
@@ -413,7 +449,7 @@ o.write = function(self, section, value)
|
||||
end
|
||||
end
|
||||
|
||||
o = s:taboption("DNS", ListValue, "singbox_dns_mode", translate("Request protocol"))
|
||||
o = s:taboption("DNS", ListValue, "singbox_dns_mode", translate("Remote DNS") .. " " .. translate("Request protocol"))
|
||||
o:value("tcp", "TCP")
|
||||
o:value("doh", "DoH")
|
||||
o:depends("dns_mode", "sing-box")
|
||||
@@ -738,6 +774,21 @@ for k, v in pairs(nodes_table) do
|
||||
else
|
||||
s2.fields["node"]:value(v.id, v["remark"])
|
||||
end
|
||||
|
||||
if v.protocol and v.protocol ~= "_shunt" then
|
||||
s.fields["dns_mode"]:depends({ dns_shunt = "chinadns-ng", tcp_node = v.id })
|
||||
s.fields["dns_mode"]:depends({ dns_shunt = "dnsmasq", tcp_node = v.id })
|
||||
if api.is_finded("smartdns") then
|
||||
s.fields["smartdns_dns_mode"]:depends({ dns_shunt = "smartdns", tcp_node = v.id })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for k, v in pairs(shunt_list) do
|
||||
s.fields["xray_dns_mode"]:depends({ [v.id .. "-type"] = "Xray", tcp_node = v.id })
|
||||
s.fields["singbox_dns_mode"]:depends({ [v.id .. "-type"] = "sing-box", tcp_node = v.id })
|
||||
s.fields["remote_dns_client_ip"]:depends({ tcp_node = v.id })
|
||||
s.fields["remote_fakedns"]:depends({ tcp_node = v.id })
|
||||
end
|
||||
|
||||
m:append(Template(appname .. "/global/footer"))
|
||||
|
||||
Reference in New Issue
Block a user