Skip to content

Commit 9b4a81b

Browse files
luci-app-passwall: bump to 26.1.25
1 parent 9bf025f commit 9b4a81b

38 files changed

+1303
-810
lines changed

applications/luci-app-passwall/Makefile

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

99
PKG_NAME:=luci-app-passwall
10-
PKG_VERSION:=26.1.17
10+
PKG_VERSION:=26.1.25
1111
PKG_RELEASE:=1
1212

1313
PKG_CONFIG_DEPENDS:= \

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ local http = require "luci.http"
1111
local util = require "luci.util"
1212
local i18n = require "luci.i18n"
1313
local jsonStringify = luci.jsonc.stringify
14+
local jsonParse = luci.jsonc.parse
1415

1516
function index()
1617
if not nixio.fs.access("/etc/config/passwall") then
@@ -79,6 +80,7 @@ function index()
7980
entry({"admin", "services", appname, "ping_node"}, call("ping_node")).leaf = true
8081
entry({"admin", "services", appname, "urltest_node"}, call("urltest_node")).leaf = true
8182
entry({"admin", "services", appname, "add_node"}, call("add_node")).leaf = true
83+
entry({"admin", "services", appname, "update_node"}, call("update_node")).leaf = true
8284
entry({"admin", "services", appname, "set_node"}, call("set_node")).leaf = true
8385
entry({"admin", "services", appname, "copy_node"}, call("copy_node")).leaf = true
8486
entry({"admin", "services", appname, "clear_all_nodes"}, call("clear_all_nodes")).leaf = true
@@ -119,6 +121,16 @@ local function http_write_json(content)
119121
http.write(jsonStringify(content or {code = 1}))
120122
end
121123

124+
local function http_write_json_ok(data)
125+
http.prepare_content("application/json")
126+
http.write(jsonStringify({code = 1, data = data}))
127+
end
128+
129+
local function http_write_json_error(data)
130+
http.prepare_content("application/json")
131+
http.write(jsonStringify({code = 0, data = data}))
132+
end
133+
122134
function reset_config()
123135
luci.sys.call('/etc/init.d/passwall stop')
124136
luci.sys.call('[ -f "/usr/share/passwall/0_default_config" ] && cp -f /usr/share/passwall/0_default_config /etc/config/passwall')
@@ -412,6 +424,8 @@ function add_node()
412424
uci:set(appname, uuid, "group", group)
413425
end
414426

427+
uci:set(appname, uuid, "type", "Xray")
428+
415429
if redirect == "1" then
416430
api.uci_save(uci, appname)
417431
http.redirect(api.url("node_config", uuid))
@@ -421,6 +435,23 @@ function add_node()
421435
end
422436
end
423437

438+
function update_node()
439+
local id = http.formvalue("id") -- Node id
440+
local data = http.formvalue("data") -- json new Data
441+
if id and data then
442+
local data_t = jsonParse(data) or {}
443+
if next(data_t) then
444+
for k, v in pairs(data_t) do
445+
uci:set(appname, id, k, v)
446+
end
447+
api.uci_save(uci, appname)
448+
http_write_json_ok()
449+
return
450+
end
451+
end
452+
http_write_json_error()
453+
end
454+
424455
function set_node()
425456
local protocol = http.formvalue("protocol")
426457
local section = http.formvalue("section")

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,19 @@ o:depends({xray_dns_mode = "tcp+doh"})
464464
o:depends({singbox_dns_mode = "doh"})
465465

466466
o = s:option(Value, "remote_dns_client_ip", translate("EDNS Client Subnet"))
467+
o.description = translate("Notify the DNS server when the DNS query is notified, the location of the client (cannot be a private IP address).") .. "<br />" ..
468+
translate("This feature requires the DNS server to support the Edns Client Subnet (RFC7871).")
467469
o.datatype = "ipaddr"
468470
o:depends({dns_mode = "sing-box"})
469471
o:depends({dns_mode = "xray"})
470472
o:depends({_node_sel_shunt = "1"})
471473

474+
o = s:option(Flag, "remote_fakedns", "FakeDNS", translate("Use FakeDNS work in the shunt domain that proxy."))
475+
o.default = "0"
476+
o.rmempty = false
477+
o:depends({dns_mode = "sing-box"})
478+
o:depends({dns_mode = "xray"})
479+
472480
o = s:option(ListValue, "chinadns_ng_default_tag", translate("Default DNS"))
473481
o.default = "none"
474482
o:value("gfw", translate("Remote DNS"))

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

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ end
9595

9696
m:append(Template(appname .. "/global/status"))
9797

98+
local global_cfgid = m:get("@global[0]")[".name"]
99+
98100
s = m:section(TypedSection, "global")
99101
s.anonymous = true
100102
s.addremove = false
@@ -118,29 +120,34 @@ o:value("", translate("Close"))
118120
o:value("tcp", translate("Same as the tcp node"))
119121
o.group = {"",""}
120122

123+
local tcp_node_id = m.uci:get(appname, global_cfgid, "tcp_node")
124+
local tcp_node = tcp_node_id and m.uci:get_all(appname, tcp_node_id) or {}
125+
121126
-- 分流
122127
if (has_singbox or has_xray) and #nodes_table > 0 then
123-
local function get_cfgvalue(shunt_node_id, option)
124-
return function(self, section)
125-
return m:get(shunt_node_id, option)
126-
end
127-
end
128-
local function get_write(shunt_node_id, option)
129-
return function(self, section, value)
130-
if s.fields["tcp_node"]:formvalue(section) == shunt_node_id then
131-
m:set(shunt_node_id, option, value)
128+
if #normal_list > 0 and tcp_node.protocol == "_shunt" then
129+
local v = tcp_node
130+
if v then
131+
local function get_cfgvalue(shunt_node_id, option)
132+
return function(self, section)
133+
return m:get(shunt_node_id, option)
134+
end
132135
end
133-
end
134-
end
135-
local function get_remove(shunt_node_id, option)
136-
return function(self, section)
137-
if s.fields["tcp_node"]:formvalue(section) == shunt_node_id then
138-
m:del(shunt_node_id, option)
136+
local function get_write(shunt_node_id, option)
137+
return function(self, section, value)
138+
if s.fields["tcp_node"]:formvalue(section) == shunt_node_id then
139+
m:set(shunt_node_id, option, value)
140+
end
141+
end
139142
end
140-
end
141-
end
142-
if #normal_list > 0 then
143-
for k, v in pairs(shunt_list) do
143+
local function get_remove(shunt_node_id, option)
144+
return function(self, section)
145+
if s.fields["tcp_node"]:formvalue(section) == shunt_node_id then
146+
m:del(shunt_node_id, option)
147+
end
148+
end
149+
end
150+
v.id = v[".name"]
144151
local vid = v.id
145152
-- shunt node type, Sing-Box or Xray
146153
o = s:taboption("Main", ListValue, vid .. "-type", translate("Type"))
@@ -161,7 +168,7 @@ if (has_singbox or has_xray) and #nodes_table > 0 then
161168
o.cfgvalue = get_cfgvalue(v.id, "preproxy_enabled")
162169
o.write = get_write(v.id, "preproxy_enabled")
163170

164-
o = s:taboption("Main", ListValue, vid .. "-main_node", string.format('<a style="color:red">%s</a>', translate("Preproxy Node")), translate("Set the node to be used as a pre-proxy. Each rule (including <code>Default</code>) has a separate switch that controls whether this rule uses the pre-proxy or not."))
171+
o = s:taboption("Main", ListValue, vid .. "-main_node", string.format('<a style="color:#FF8C00">%s</a>', translate("Preproxy Node")), translate("Set the node to be used as a pre-proxy. Each rule (including <code>Default</code>) has a separate switch that controls whether this rule uses the pre-proxy or not."))
165172
o:depends(vid .. "-preproxy_enabled", "1")
166173
o.template = appname .. "/cbi/nodes_listvalue"
167174
o.group = {}
@@ -188,6 +195,12 @@ if (has_singbox or has_xray) and #nodes_table > 0 then
188195
o.cfgvalue = get_cfgvalue(v.id, "main_node")
189196
o.write = get_write(v.id, "main_node")
190197

198+
o = s:taboption("Main", Flag, vid .. "-fakedns", "FakeDNS", translate("Use FakeDNS work in the shunt domain that proxy."))
199+
o:depends("tcp_node", v.id)
200+
o.cfgvalue = get_cfgvalue(v.id, "fakedns")
201+
o.write = get_write(v.id, "fakedns")
202+
o.remove = get_remove(v.id, "fakedns")
203+
191204
m.uci:foreach(appname, "shunt_rules", function(e)
192205
local id = e[".name"]
193206
local node_option = vid .. "-" .. id .. "_node"
@@ -204,16 +217,23 @@ if (has_singbox or has_xray) and #nodes_table > 0 then
204217
o.template = appname .. "/cbi/nodes_listvalue"
205218
o.group = {"","","",""}
206219

207-
local pt = s:taboption("Main", ListValue, vid .. "-".. id .. "_proxy_tag", string.format('* <a style="color:red">%s</a>', e.remarks .. " " .. translate("Preproxy")))
220+
local pt = s:taboption("Main", ListValue, vid .. "-".. id .. "_proxy_tag", string.format('* <a style="color:#FF8C00">%s</a>', e.remarks .. " " .. translate("Preproxy")))
208221
pt.cfgvalue = get_cfgvalue(v.id, id .. "_proxy_tag")
209222
pt.write = get_write(v.id, id .. "_proxy_tag")
210223
pt.remove = get_remove(v.id, id .. "_proxy_tag")
211224
pt:value("", translate("Close"))
212225
pt:value("main", translate("Preproxy Node"))
213226
pt:depends("__hide__", "1")
227+
228+
local fakedns_tag = s:taboption("Main", Flag, vid .. "-".. id .. "_fakedns", string.format('* <a style="color:#FF8C00">%s</a>', e.remarks .. " " .. "FakeDNS"))
229+
fakedns_tag.cfgvalue = get_cfgvalue(v.id, id .. "_fakedns")
230+
fakedns_tag.write = get_write(v.id, id .. "_fakedns")
231+
fakedns_tag.remove = get_remove(v.id, id .. "_fakedns")
232+
214233
for k1, v1 in pairs(socks_list) do
215234
o:value(v1.id, v1.remark)
216235
o.group[#o.group+1] = (v1.group and v1.group ~= "") and v1.group or translate("default")
236+
fakedns_tag:depends({ [node_option] = v1.id, [vid .. "-fakedns"] = "1" })
217237
end
218238
for k1, v1 in pairs(balancing_list) do
219239
o:value(v1.id, v1.remark)
@@ -233,6 +253,10 @@ if (has_singbox or has_xray) and #nodes_table > 0 then
233253
if not api.is_local_ip(v1.address) then --本地节点禁止使用前置
234254
pt:depends({ [node_option] = v1.id, [vid .. "-preproxy_enabled"] = "1" })
235255
end
256+
fakedns_tag:depends({ [node_option] = v1.id, [vid .. "-fakedns"] = "1" })
257+
end
258+
if v.default_node ~= "_direct" or v.default_node ~= "_blackhole" then
259+
fakedns_tag:depends({ [node_option] = "_default", [vid .. "-fakedns"] = "1" })
236260
end
237261
end
238262
end)
@@ -269,7 +293,7 @@ if (has_singbox or has_xray) and #nodes_table > 0 then
269293
end
270294

271295
local id = "default_proxy_tag"
272-
o = s:taboption("Main", ListValue, vid .. "-" .. id, string.format('* <a style="color:red">%s</a>', translate("Default Preproxy")), translate("When using, localhost will connect this node first and then use this node to connect the default node."))
296+
o = s:taboption("Main", ListValue, vid .. "-" .. id, string.format('* <a style="color:#FF8C00">%s</a>', translate("Default Preproxy")), translate("When using, localhost will connect this node first and then use this node to connect the default node."))
273297
o.cfgvalue = get_cfgvalue(v.id, id)
274298
o.write = get_write(v.id, id)
275299
o.remove = get_remove(v.id, id)
@@ -335,7 +359,7 @@ if api.is_finded("smartdns") then
335359
o = s:taboption("DNS", Value, "group_domestic", translate("Domestic group name"))
336360
o.placeholder = "local"
337361
o:depends("dns_shunt", "smartdns")
338-
o.description = translate("You only need to configure domestic DNS packets in SmartDNS and set it redirect or as Dnsmasq upstream, and fill in the domestic DNS group name here.")
362+
o.description = translate("You only need to configure domestic DNS packets in SmartDNS, and fill in the domestic DNS group name here.")
339363
end
340364

341365
o = s:taboption("DNS", ListValue, "direct_dns_mode", translate("Direct DNS") .. " " .. translate("Request protocol"))
@@ -559,7 +583,7 @@ o:depends({singbox_dns_mode = "doh"})
559583

560584
o = s:taboption("DNS", Value, "remote_dns_client_ip", translate("EDNS Client Subnet"))
561585
o.description = translate("Notify the DNS server when the DNS query is notified, the location of the client (cannot be a private IP address).") .. "<br />" ..
562-
translate("This feature requires the DNS server to support the Edns Client Subnet (RFC7871).")
586+
translate("This feature requires the DNS server to support the Edns Client Subnet (RFC7871).")
563587
o.datatype = "ipaddr"
564588
o:depends({dns_mode = "sing-box"})
565589
o:depends({dns_mode = "xray"})
@@ -574,7 +598,7 @@ o:depends({smartdns_dns_mode = "sing-box", dns_shunt = "smartdns"})
574598
o:depends({dns_mode = "xray", dns_shunt = "dnsmasq"})
575599
o:depends({dns_mode = "xray", dns_shunt = "chinadns-ng"})
576600
o:depends({smartdns_dns_mode = "xray", dns_shunt = "smartdns"})
577-
o:depends("_node_sel_shunt", "1")
601+
--o:depends("_node_sel_shunt", "1")
578602
o.validate = function(self, value, t)
579603
if value and value == "1" then
580604
local _dns_mode = s.fields["dns_mode"]:formvalue(t)
@@ -924,6 +948,10 @@ for k, v in pairs(nodes_table) do
924948
end
925949
end
926950

927-
m:append(Template(appname .. "/global/footer"))
951+
local footer = Template(appname .. "/global/footer")
952+
footer.api = api
953+
footer.global_cfgid = global_cfgid
954+
footer.shunt_list = api.jsonc.stringify(shunt_list)
955+
m:append(footer)
928956

929957
return m

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

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

12+
local header = Template(appname .. "/node_config/header")
13+
header.api = api
14+
header.section = arg[1]
15+
m:append(header)
16+
1217
m:append(Template(appname .. "/cbi/nodes_multivalue_com"))
1318
m:append(Template(appname .. "/cbi/nodes_listvalue_com"))
1419

@@ -18,7 +23,7 @@ s.dynamic = false
1823

1924
o = s:option(DummyValue, "passwall", " ")
2025
o.rawhtml = true
21-
o.template = "passwall/node_list/link_share_man"
26+
o.template = "passwall/node_config/link_share_man"
2227
o.value = arg[1]
2328

2429
o = s:option(Value, "remarks", translate("Node Remarks"))
@@ -55,35 +60,40 @@ o.write = function(self, section, value)
5560
m:set(section, self.option, value)
5661
end
5762

63+
local fs = api.fs
64+
local types_dir = "/usr/lib/lua/luci/model/cbi/passwall/client/type/"
65+
s.val = {}
66+
s.val["type"] = m.uci:get(appname, arg[1], "type")
67+
s.val["protocol"] = m.uci:get(appname, arg[1], "protocol")
68+
5869
o = s:option(ListValue, "type", translate("Type"))
5970

6071
if api.is_finded("ipt2socks") then
61-
local function _n(name)
62-
return "socks_" .. name
63-
end
64-
6572
s.fields["type"]:value("Socks", translate("Socks"))
6673

67-
o = s:option(ListValue, _n("del_protocol"), " ") --始终隐藏,用于删除 protocol
68-
o:depends({ [_n("__hide")] = "1" })
69-
o.rewrite_option = "protocol"
74+
if s.val["type"] == "Socks" then
75+
local function _n(name)
76+
return "socks_" .. name
77+
end
78+
o = s:option(ListValue, _n("del_protocol"), " ") --始终隐藏,用于删除 protocol
79+
o:depends({ [_n("__hide")] = "1" })
80+
o.rewrite_option = "protocol"
81+
82+
o = s:option(Value, _n("address"), translate("Address (Support Domain Name)"))
7083

71-
o = s:option(Value, _n("address"), translate("Address (Support Domain Name)"))
84+
o = s:option(Value, _n("port"), translate("Port"))
85+
o.datatype = "port"
7286

73-
o = s:option(Value, _n("port"), translate("Port"))
74-
o.datatype = "port"
87+
o = s:option(Value, _n("username"), translate("Username"))
7588

76-
o = s:option(Value, _n("username"), translate("Username"))
89+
o = s:option(Value, _n("password"), translate("Password"))
90+
o.password = true
7791

78-
o = s:option(Value, _n("password"), translate("Password"))
79-
o.password = true
92+
api.luci_types(arg[1], m, s, "Socks", "socks_")
93+
end
8094

81-
api.luci_types(arg[1], m, s, "Socks", "socks_")
8295
end
8396

84-
local fs = api.fs
85-
local types_dir = "/usr/lib/lua/luci/model/cbi/passwall/client/type/"
86-
8797
local type_table = {}
8898
for filename in fs.dir(types_dir) do
8999
table.insert(type_table, filename)
@@ -95,4 +105,10 @@ for index, value in ipairs(type_table) do
95105
setfenv(p_func, getfenv(1))(m, s)
96106
end
97107

108+
local footer = Template(appname .. "/node_config/footer")
109+
footer.api = api
110+
footer.section = arg[1]
111+
112+
m:append(footer)
113+
98114
return m

0 commit comments

Comments
 (0)