Skip to content

Commit 6da11f8

Browse files
luci-app-passwall: bump to 25.12.13
1 parent cb1d7d7 commit 6da11f8

File tree

39 files changed

+3134
-617
lines changed

39 files changed

+3134
-617
lines changed

applications/luci-app-passwall/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
include $(TOPDIR)/rules.mk
77

88
PKG_NAME:=luci-app-passwall
9-
PKG_VERSION:=25.11.14
9+
PKG_VERSION:=25.12.13
1010
PKG_RELEASE:=1
1111

1212
PKG_CONFIG_DEPENDS:= \

applications/luci-app-passwall/htdocs/luci-static/resources/view/passwall/Sortable.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applications/luci-app-passwall/htdocs/luci-static/resources/view/passwall/popper.min.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applications/luci-app-passwall/luasrc/controller/passwall.lua

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ function index()
8282
entry({"admin", "services", appname, "copy_node"}, call("copy_node")).leaf = true
8383
entry({"admin", "services", appname, "clear_all_nodes"}, call("clear_all_nodes")).leaf = true
8484
entry({"admin", "services", appname, "delete_select_nodes"}, call("delete_select_nodes")).leaf = true
85+
entry({"admin", "services", appname, "reassign_group"}, call("reassign_group")).leaf = true
8586
entry({"admin", "services", appname, "get_node"}, call("get_node")).leaf = true
87+
entry({"admin", "services", appname, "save_node_order"}, call("save_node_order")).leaf = true
88+
entry({"admin", "services", appname, "save_node_list_opt"}, call("save_node_list_opt")).leaf = true
8689
entry({"admin", "services", appname, "update_rules"}, call("update_rules")).leaf = true
8790
entry({"admin", "services", appname, "subscribe_del_node"}, call("subscribe_del_node")).leaf = true
8891
entry({"admin", "services", appname, "subscribe_del_all"}, call("subscribe_del_all")).leaf = true
@@ -301,7 +304,8 @@ function index_status()
301304
end
302305

303306
function haproxy_status()
304-
local e = luci.sys.call(string.format("/bin/busybox top -bn1 | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null", appname)) == 0
307+
local e = {}
308+
e["status"] = luci.sys.call(string.format("/bin/busybox top -bn1 | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null", appname)) == 0
305309
http_write_json(e)
306310
end
307311

@@ -407,6 +411,11 @@ function add_node()
407411
local uuid = api.gen_short_uuid()
408412
uci:section(appname, "nodes", uuid)
409413

414+
local group = http.formvalue("group")
415+
if group and group ~= "default" then
416+
uci:set(appname, uuid, "group", group)
417+
end
418+
410419
if redirect == "1" then
411420
api.uci_save(uci, appname)
412421
http.redirect(api.url("node_config", uuid))
@@ -420,6 +429,20 @@ function set_node()
420429
local protocol = http.formvalue("protocol")
421430
local section = http.formvalue("section")
422431
uci:set(appname, "@global[0]", protocol .. "_node", section)
432+
if protocol == "tcp" then
433+
local node_protocol = uci:get(appname, section, "protocol")
434+
if node_protocol == "_shunt" then
435+
local type = uci:get(appname, section, "type")
436+
local dns_shunt = uci:get(appname, "@global[0]", "dns_shunt")
437+
local dns_key = (dns_shunt == "smartdns") and "smartdns_dns_mode" or "dns_mode"
438+
local dns_mode = uci:get(appname, "@global[0]", dns_key)
439+
local new_dns_mode = (type == "Xray") and "xray" or "sing-box"
440+
if dns_mode ~= new_dns_mode then
441+
uci:set(appname, "@global[0]", dns_key, new_dns_mode)
442+
uci:set(appname, "@global[0]", "v2ray_dns_mode", "tcp")
443+
end
444+
end
445+
end
423446
api.uci_save(uci, appname, true, true)
424447
http.redirect(api.url("log"))
425448
end
@@ -571,13 +594,12 @@ function delete_select_nodes()
571594
end
572595
end
573596

574-
575597
function get_node()
576598
local id = http.formvalue("id")
577599
local result = {}
578-
local show_node_info = api.uci_get_type("@global_other[0]", "show_node_info", "0")
600+
local show_node_info = api.uci_get_type("global_other", "show_node_info", "0")
579601

580-
function add_is_ipv6_key(o)
602+
local function add_is_ipv6_key(o)
581603
if o and o.address and show_node_info == "1" then
582604
local f = api.get_ipv6_full(o.address)
583605
if f ~= "" then
@@ -591,14 +613,58 @@ function get_node()
591613
result = uci:get_all(appname, id)
592614
add_is_ipv6_key(result)
593615
else
616+
local default_nodes = {}
617+
local other_nodes = {}
594618
uci:foreach(appname, "nodes", function(t)
595619
add_is_ipv6_key(t)
596-
result[#result + 1] = t
620+
if not t.group or t.group == "" then
621+
default_nodes[#default_nodes + 1] = t
622+
else
623+
other_nodes[#other_nodes + 1] = t
624+
end
597625
end)
626+
for i = 1, #default_nodes do result[#result + 1] = default_nodes[i] end
627+
for i = 1, #other_nodes do result[#result + 1] = other_nodes[i] end
598628
end
599629
http_write_json(result)
600630
end
601631

632+
function save_node_order()
633+
local ids = http.formvalue("ids") or ""
634+
local new_order = {}
635+
for id in ids:gmatch("([^,]+)") do
636+
new_order[#new_order + 1] = id
637+
end
638+
for idx, name in ipairs(new_order) do
639+
luci.sys.call(string.format("uci -q reorder %s.%s=%d", appname, name, idx - 1))
640+
end
641+
api.sh_uci_commit(appname)
642+
http_write_json({ status = "ok" })
643+
end
644+
645+
function reassign_group()
646+
local ids = http.formvalue("ids") or ""
647+
local group = http.formvalue("group") or "default"
648+
for id in ids:gmatch("([^,]+)") do
649+
if group ~="" and group ~= "default" then
650+
api.sh_uci_set(appname, id, "group", group)
651+
else
652+
api.sh_uci_del(appname, id, "group")
653+
end
654+
end
655+
api.sh_uci_commit(appname)
656+
http_write_json({ status = "ok" })
657+
end
658+
659+
function save_node_list_opt()
660+
local option = http.formvalue("option") or ""
661+
local value = http.formvalue("value") or ""
662+
if option ~= "" then
663+
api.sh_uci_set(appname, "@global_other[0]", option, value, true)
664+
end
665+
http_write_json({ status = "ok" })
666+
end
667+
602668
function update_rules()
603669
local update = http.formvalue("update")
604670
luci.sys.call("lua /usr/share/passwall/rule_update.lua log '" .. update .. "' > /dev/null 2>&1 &")

applications/luci-app-passwall/luasrc/model/cbi/passwall/client/acl_config.lua

Lines changed: 105 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ if not arg[1] or not m:get(arg[1]) then
99
luci.http.redirect(m.redirect)
1010
end
1111

12+
if api.is_js_luci() then
13+
m:append(Template(appname .. "/cbi/nodes_listvalue_com"))
14+
end
15+
1216
local fs = api.fs
1317
local sys = api.sys
1418
local has_singbox = api.finded_com("sing-box")
@@ -22,11 +26,17 @@ local port_validate = function(self, value, t)
2226
end
2327

2428
local nodes_table = {}
25-
local shunt_list = {}
26-
for k, e in ipairs(api.get_valid_nodes()) do
29+
for _, e in ipairs(api.get_valid_nodes()) do
2730
nodes_table[#nodes_table + 1] = e
2831
end
2932

33+
local normal_list = {}
34+
for _, v in pairs(nodes_table) do
35+
if v.node_type == "normal" then
36+
normal_list[#normal_list + 1] = v
37+
end
38+
end
39+
3040
local dynamicList_write = function(self, section, value)
3141
local t = {}
3242
local t2 = {}
@@ -188,6 +198,10 @@ o:depends({ _hide_node_option = "1", ['!reverse'] = true })
188198
o = s:option(ListValue, "tcp_node", "<a style='color: red'>" .. translate("TCP Node") .. "</a>")
189199
o.default = ""
190200
o:depends({ _hide_node_option = false, use_global_config = false })
201+
if api.is_js_luci() then
202+
o.template = appname .. "/cbi/nodes_listvalue"
203+
end
204+
o.group = {}
191205

192206
o = s:option(DummyValue, "_tcp_node_bool", "")
193207
o.template = "passwall/cbi/hidevalue"
@@ -199,14 +213,10 @@ o.default = ""
199213
o:value("", translate("Close"))
200214
o:value("tcp", translate("Same as the tcp node"))
201215
o:depends({ _tcp_node_bool = "1" })
202-
203-
for k, v in pairs(nodes_table) do
204-
s.fields["tcp_node"]:value(v.id, v["remark"])
205-
s.fields["udp_node"]:value(v.id, v["remark"])
206-
if v.protocol and v.protocol == "_shunt" then
207-
shunt_list[#shunt_list + 1] = v
208-
end
216+
if api.is_js_luci() then
217+
o.template = appname .. "/cbi/nodes_listvalue"
209218
end
219+
o.group = {"",""}
210220

211221
o = s:option(DummyValue, "_udp_node_bool", "")
212222
o.template = "passwall/cbi/hidevalue"
@@ -260,6 +270,8 @@ o.cfgvalue = function(t, n)
260270
return string.format('<font color="red">%s</font>',
261271
translate("The port settings support single ports and ranges.<br>Separate multiple ports with commas (,).<br>Example: 21,80,443,1000:2000."))
262272
end
273+
o:depends({ use_global_config = true })
274+
o:depends({ _tcp_node_bool = "1" })
263275

264276
o = s:option(Flag, "use_direct_list", translatef("Use %s", translate("Direct List")))
265277
o.default = "1"
@@ -333,15 +345,25 @@ o.remove = function(self, section)
333345
if id_val == "" then
334346
return m:del(section, self.option)
335347
end
336-
for k, v in pairs(shunt_list) do
348+
for _, v in pairs(nodes_table) do
337349
if v.id == id_val then
338350
local new_val = (v.type == "Xray") and "xray" or "sing-box"
339-
return m:set(section, self.option, new_val)
351+
m:set(section, self.option, new_val)
352+
353+
local dns_field = s.fields[v.type == "Xray" and "xray_dns_mode" or "singbox_dns_mode"]
354+
local v2ray_dns_mode = dns_field and dns_field:formvalue(section)
355+
if v2ray_dns_mode then
356+
m:set(section, "v2ray_dns_mode", v2ray_dns_mode)
357+
end
358+
359+
break
340360
end
341361
end
342362
end
343363

344364
o = s:option(ListValue, "xray_dns_mode", translate("Request protocol"))
365+
o.default = "tcp"
366+
o:value("udp", "UDP")
345367
o:value("tcp", "TCP")
346368
o:value("tcp+doh", "TCP + DoH (" .. translate("A/AAAA type") .. ")")
347369
o:depends("dns_mode", "xray")
@@ -355,6 +377,8 @@ o.write = function(self, section, value)
355377
end
356378

357379
o = s:option(ListValue, "singbox_dns_mode", translate("Request protocol"))
380+
o.default = "tcp"
381+
o:value("udp", "UDP")
358382
o:value("tcp", "TCP")
359383
o:value("doh", "DoH")
360384
o:depends("dns_mode", "sing-box")
@@ -379,53 +403,53 @@ o:value("149.112.112.112", "149.112.112.112 (Quad9-Recommended)")
379403
o:value("208.67.220.220", "208.67.220.220 (OpenDNS)")
380404
o:value("208.67.222.222", "208.67.222.222 (OpenDNS)")
381405
o:depends({dns_mode = "dns2socks"})
406+
o:depends({xray_dns_mode = "udp"})
382407
o:depends({xray_dns_mode = "tcp"})
383408
o:depends({xray_dns_mode = "tcp+doh"})
409+
o:depends({singbox_dns_mode = "udp"})
384410
o:depends({singbox_dns_mode = "tcp"})
385411

386-
if has_singbox or has_xray then
387-
o = s:option(Value, "remote_dns_doh", translate("Remote DNS DoH"))
388-
o:value("https://1.1.1.1/dns-query", "CloudFlare")
389-
o:value("https://1.1.1.2/dns-query", "CloudFlare-Security")
390-
o:value("https://8.8.4.4/dns-query", "Google 8844")
391-
o:value("https://8.8.8.8/dns-query", "Google 8888")
392-
o:value("https://9.9.9.9/dns-query", "Quad9-Recommended 9.9.9.9")
393-
o:value("https://149.112.112.112/dns-query", "Quad9-Recommended 149.112.112.112")
394-
o:value("https://208.67.222.222/dns-query", "OpenDNS")
395-
o:value("https://dns.adguard.com/dns-query,176.103.130.130", "AdGuard")
396-
o:value("https://doh.libredns.gr/dns-query,116.202.176.26", "LibreDNS")
397-
o:value("https://doh.libredns.gr/ads,116.202.176.26", "LibreDNS (No Ads)")
398-
o.default = "https://1.1.1.1/dns-query"
399-
o.validate = function(self, value, t)
400-
if value ~= "" then
401-
value = api.trim(value)
402-
local flag = 0
403-
local util = require "luci.util"
404-
local val = util.split(value, ",")
405-
local url = val[1]
406-
val[1] = nil
407-
for i = 1, #val do
408-
local v = val[i]
409-
if v then
410-
if not api.datatypes.ipmask4(v) then
411-
flag = 1
412-
end
412+
o = s:option(Value, "remote_dns_doh", translate("Remote DNS DoH"))
413+
o:value("https://1.1.1.1/dns-query", "1.1.1.1 (CloudFlare)")
414+
o:value("https://1.1.1.2/dns-query", "1.1.1.2 (CloudFlare-Security)")
415+
o:value("https://8.8.4.4/dns-query", "8.8.4.4 (Google)")
416+
o:value("https://8.8.8.8/dns-query", "8.8.8.8 (Google)")
417+
o:value("https://9.9.9.9/dns-query", "9.9.9.9 (Quad9)")
418+
o:value("https://149.112.112.112/dns-query", "149.112.112.112 (Quad9)")
419+
o:value("https://208.67.222.222/dns-query", "208.67.222.222 (OpenDNS)")
420+
o:value("https://dns.adguard.com/dns-query,94.140.14.14", "94.140.14.14 (AdGuard)")
421+
o:value("https://doh.libredns.gr/dns-query,116.202.176.26", "116.202.176.26 (LibreDNS)")
422+
o:value("https://doh.libredns.gr/ads,116.202.176.26", "116.202.176.26 (LibreDNS-NoAds)")
423+
o.default = "https://1.1.1.1/dns-query"
424+
o.validate = function(self, value, t)
425+
if value ~= "" then
426+
value = api.trim(value)
427+
local flag = 0
428+
local util = require "luci.util"
429+
local val = util.split(value, ",")
430+
local url = val[1]
431+
val[1] = nil
432+
for i = 1, #val do
433+
local v = val[i]
434+
if v then
435+
if not api.datatypes.ipmask4(v) then
436+
flag = 1
413437
end
414438
end
415-
if flag == 0 then
416-
return value
417-
end
418439
end
419-
return nil, translate("DoH request address") .. " " .. translate("Format must be:") .. " URL,IP"
440+
if flag == 0 then
441+
return value
442+
end
420443
end
421-
o:depends({xray_dns_mode = "tcp+doh"})
422-
o:depends({singbox_dns_mode = "doh"})
423-
424-
o = s:option(Value, "remote_dns_client_ip", translate("EDNS Client Subnet"))
425-
o.datatype = "ipaddr"
426-
o:depends({dns_mode = "sing-box"})
427-
o:depends({dns_mode = "xray"})
444+
return nil, translate("DoH request address") .. " " .. translate("Format must be:") .. " URL,IP"
428445
end
446+
o:depends({xray_dns_mode = "tcp+doh"})
447+
o:depends({singbox_dns_mode = "doh"})
448+
449+
o = s:option(Value, "remote_dns_client_ip", translate("EDNS Client Subnet"))
450+
o.datatype = "ipaddr"
451+
o:depends({dns_mode = "sing-box"})
452+
o:depends({dns_mode = "xray"})
429453

430454
o = s:option(ListValue, "chinadns_ng_default_tag", translate("Default DNS"))
431455
o.default = "none"
@@ -452,20 +476,40 @@ o:value("direct", translate("Direct DNS"))
452476
o.description = desc .. "</ul>"
453477
o:depends({dns_shunt = "dnsmasq", tcp_proxy_mode = "proxy", chn_list = "direct"})
454478

479+
local tcp = s.fields["tcp_node"]
480+
local udp = s.fields["udp_node"]
455481
for k, v in pairs(nodes_table) do
456-
if v.protocol ~= "_shunt" then
457-
s.fields["dns_mode"]:depends({ _tcp_node_bool = "1", tcp_node = v.id })
458-
end
459-
end
460-
for k, v in pairs(shunt_list) do
461-
if v.type == "Xray" and has_xray then
462-
s.fields["xray_dns_mode"]:depends({ _tcp_node_bool = "1", tcp_node = v.id })
463-
end
464-
if v.type == "sing-box" and has_singbox then
465-
s.fields["singbox_dns_mode"]:depends({ _tcp_node_bool = "1", tcp_node = v.id })
482+
if #normal_list == 0 then
483+
s.fields["dns_mode"]:depends({ _tcp_node_bool = "1" })
484+
break
466485
end
467-
if has_xray or has_singbox then
468-
s.fields["remote_dns_client_ip"]:depends({ tcp_node = v.id })
486+
if v.protocol == "_shunt" then
487+
if v.type == "Xray" and has_xray then
488+
tcp:value(v.id, v["remark"])
489+
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
490+
udp:value(v.id, v["remark"])
491+
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
492+
493+
s.fields["xray_dns_mode"]:depends({ _tcp_node_bool = "1", tcp_node = v.id })
494+
end
495+
if v.type == "sing-box" and has_singbox then
496+
tcp:value(v.id, v["remark"])
497+
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
498+
udp:value(v.id, v["remark"])
499+
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
500+
501+
s.fields["singbox_dns_mode"]:depends({ _tcp_node_bool = "1", tcp_node = v.id })
502+
end
503+
if has_xray or has_singbox then
504+
s.fields["remote_dns_client_ip"]:depends({ tcp_node = v.id })
505+
end
506+
else
507+
tcp:value(v.id, v["remark"])
508+
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
509+
udp:value(v.id, v["remark"])
510+
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
511+
512+
s.fields["dns_mode"]:depends({ _tcp_node_bool = "1", tcp_node = v.id })
469513
end
470514
end
471515

0 commit comments

Comments
 (0)