luci-app-passwall: sync upstream

last commit: cc2d8e3c8a
This commit is contained in:
gitea-action 2025-01-14 23:30:26 +08:00
parent 53daef9365
commit 27a7fc520f
15 changed files with 68 additions and 23 deletions

View File

@ -3,6 +3,7 @@ local appname = "passwall"
local sys = api.sys local sys = api.sys
m = Map(appname) m = Map(appname)
api.set_apply_on_parse(m)
s = m:section(TypedSection, "global", translate("ACLs"), "<font color='red'>" .. translate("ACLs is a tools which used to designate specific IP proxy mode.") .. "</font>") s = m:section(TypedSection, "global", translate("ACLs"), "<font color='red'>" .. translate("ACLs is a tools which used to designate specific IP proxy mode.") .. "</font>")
s.anonymous = true s.anonymous = true

View File

@ -2,6 +2,7 @@ local api = require "luci.passwall.api"
local appname = "passwall" local appname = "passwall"
m = Map(appname) m = Map(appname)
api.set_apply_on_parse(m)
-- [[ App Settings ]]-- -- [[ App Settings ]]--
s = m:section(TypedSection, "global_app", translate("App Update"), s = m:section(TypedSection, "global_app", translate("App Update"),

View File

@ -10,6 +10,7 @@ local has_chnroute = fs.access("/usr/share/passwall/rules/chnroute")
local chinadns_tls = os.execute("chinadns-ng -V | grep -i wolfssl >/dev/null") local chinadns_tls = os.execute("chinadns-ng -V | grep -i wolfssl >/dev/null")
m = Map(appname) m = Map(appname)
api.set_apply_on_parse(m)
local nodes_table = {} local nodes_table = {}
for k, e in ipairs(api.get_valid_nodes()) do for k, e in ipairs(api.get_valid_nodes()) do

View File

@ -15,6 +15,7 @@ for k, e in ipairs(api.get_valid_nodes()) do
end end
m = Map(appname) m = Map(appname)
api.set_apply_on_parse(m)
-- [[ Haproxy Settings ]]-- -- [[ Haproxy Settings ]]--
s = m:section(TypedSection, "global_haproxy", translate("Basic Settings")) s = m:section(TypedSection, "global_haproxy", translate("Basic Settings"))

View File

@ -4,6 +4,7 @@ local sys = api.sys
local datatypes = api.datatypes local datatypes = api.datatypes
m = Map(appname) m = Map(appname)
api.set_apply_on_parse(m)
-- [[ Other Settings ]]-- -- [[ Other Settings ]]--
s = m:section(TypedSection, "global_other") s = m:section(TypedSection, "global_other")

View File

@ -1,4 +1,5 @@
local api = require "luci.passwall.api" local api = require "luci.passwall.api"
local uci = require "luci.model.uci".cursor()
local appname = "passwall" local appname = "passwall"
local has_ss = api.is_finded("ss-redir") local has_ss = api.is_finded("ss-redir")
local has_ss_rust = api.is_finded("sslocal") local has_ss_rust = api.is_finded("sslocal")
@ -45,10 +46,6 @@ end
m = Map(appname) m = Map(appname)
-- [[ Subscribe Settings ]]--
s = m:section(TypedSection, "global_subscribe", "")
s.anonymous = true
function m.commit_handler(self) function m.commit_handler(self)
if self.no_commit then if self.no_commit then
return return
@ -58,6 +55,21 @@ function m.commit_handler(self)
end) end)
end end
if api.is_js_luci() then
m.apply_on_parse = false
m.on_after_apply = function(self)
uci:foreach(appname, "subscribe_list", function(e)
uci:delete(appname, e[".name"], "md5")
end)
uci:commit(appname)
api.showMsg_Redirect()
end
end
-- [[ Subscribe Settings ]]--
s = m:section(TypedSection, "global_subscribe", "")
s.anonymous = true
o = s:option(ListValue, "filter_keyword_mode", translate("Filter keyword Mode")) o = s:option(ListValue, "filter_keyword_mode", translate("Filter keyword Mode"))
o:value("0", translate("Close")) o:value("0", translate("Close"))
o:value("1", translate("Discard List")) o:value("1", translate("Discard List"))

View File

@ -18,13 +18,7 @@ if api.is_js_luci() then
m.on_after_apply = function(self) m.on_after_apply = function(self)
uci:delete(appname, arg[1], "md5") uci:delete(appname, arg[1], "md5")
uci:commit(appname) uci:commit(appname)
luci.http.write([[ api.showMsg_Redirect(self.redirect, 3000)
<script type="text/javascript">
setTimeout(function() {
window.location.href = ']] .. self.redirect .. [[';
}, 1000);
</script>
]])
end end
end end

View File

@ -11,6 +11,7 @@ local port_validate = function(self, value, t)
end end
m = Map(appname) m = Map(appname)
api.set_apply_on_parse(m)
-- [[ Delay Settings ]]-- -- [[ Delay Settings ]]--
s = m:section(TypedSection, "global_delay", translate("Delay Settings")) s = m:section(TypedSection, "global_delay", translate("Delay Settings"))

View File

@ -4,6 +4,8 @@ local has_xray = api.finded_com("xray")
local has_singbox = api.finded_com("singbox") local has_singbox = api.finded_com("singbox")
m = Map(appname) m = Map(appname)
api.set_apply_on_parse(m)
-- [[ Rule Settings ]]-- -- [[ Rule Settings ]]--
s = m:section(TypedSection, "global_rules", translate("Rule status")) s = m:section(TypedSection, "global_rules", translate("Rule status"))
s.anonymous = true s.anonymous = true

View File

@ -9,6 +9,7 @@ local chnlist_path = "/usr/share/passwall/rules/chnlist"
local chnroute_path = "/usr/share/passwall/rules/chnroute" local chnroute_path = "/usr/share/passwall/rules/chnroute"
m = Map(appname) m = Map(appname)
api.set_apply_on_parse(m)
-- [[ Rule List Settings ]]-- -- [[ Rule List Settings ]]--
s = m:section(TypedSection, "global_rules") s = m:section(TypedSection, "global_rules")

View File

@ -4,6 +4,7 @@ local datatypes = api.datatypes
m = Map(appname, "Sing-Box/Xray " .. translate("Shunt Rule")) m = Map(appname, "Sing-Box/Xray " .. translate("Shunt Rule"))
m.redirect = api.url() m.redirect = api.url()
api.set_apply_on_parse(m)
s = m:section(NamedSection, arg[1], "shunt_rules", "") s = m:section(NamedSection, arg[1], "shunt_rules", "")
s.addremove = false s.addremove = false

View File

@ -1,6 +1,7 @@
local api = require "luci.passwall.api" local api = require "luci.passwall.api"
m = Map("passwall_server", translate("Server-Side")) m = Map("passwall_server", translate("Server-Side"))
api.set_apply_on_parse(m)
t = m:section(NamedSection, "global", "global") t = m:section(NamedSection, "global", "global")
t.anonymous = true t.anonymous = true

View File

@ -45,18 +45,43 @@ function set_apply_on_parse(map)
if is_js_luci() then if is_js_luci() then
map.apply_on_parse = false map.apply_on_parse = false
map.on_after_apply = function(self) map.on_after_apply = function(self)
if self.redirect then showMsg_Redirect(self.redirect, 3000)
end
end
end
function showMsg_Redirect(redirectUrl, delay)
local message = "PassWall " .. i18n.translate("Settings have been successfully saved and applied!")
luci.http.write([[ luci.http.write([[
<script type="text/javascript"> <script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
var messageDiv = document.createElement('div');
messageDiv.style.position = 'fixed';
messageDiv.style.top = '0';
messageDiv.style.left = '0';
messageDiv.style.width = '100%';
messageDiv.style.background = '#4caf50';
messageDiv.style.color = '#fff';
messageDiv.style.textAlign = 'center';
messageDiv.style.padding = '10px';
messageDiv.style.zIndex = '10000';
messageDiv.textContent = ']] .. message .. [[';
document.body.appendChild(messageDiv);
var redirectUrl = ']] .. (redirectUrl or "") .. [[';
var delay = ]] .. (delay or 3000) .. [[;
setTimeout(function() { setTimeout(function() {
window.location.href = ']] .. self.redirect .. [['; if (redirectUrl) {
}, 1000); window.location.href = redirectUrl;
} else {
if (messageDiv && messageDiv.parentNode) {
messageDiv.parentNode.removeChild(messageDiv);
}
}
}, delay);
});
</script> </script>
]]) ]])
end end
end
end
end
function uci_save(cursor, config, commit, apply) function uci_save(cursor, config, commit, apply)
if is_old_uci() then if is_old_uci() then

View File

@ -1800,3 +1800,6 @@ msgstr "是否要恢复客户端默认配置?"
msgid "Are you sure you want to restore the client to default settings?" msgid "Are you sure you want to restore the client to default settings?"
msgstr "是否真的要恢复客户端默认配置?" msgstr "是否真的要恢复客户端默认配置?"
msgid "Settings have been successfully saved and applied!"
msgstr "设置已成功保存并应用!"

View File

@ -20,10 +20,10 @@ index f0c9835..3555afe 100644
define Package/$(PKG_NAME)/postrm define Package/$(PKG_NAME)/postrm
diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua 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 de67f1c..463bdff 100644 index 3e98ec5..17184a5 100644
--- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua
+++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua
@@ -492,6 +492,12 @@ o:value("9.9.9.9", "9.9.9.9 (Quad9)") @@ -493,6 +493,12 @@ o:value("9.9.9.9", "9.9.9.9 (Quad9)")
o:value("149.112.112.112", "149.112.112.112 (Quad9)") o:value("149.112.112.112", "149.112.112.112 (Quad9)")
o:value("208.67.220.220", "208.67.220.220 (OpenDNS)") o:value("208.67.220.220", "208.67.220.220 (OpenDNS)")
o:value("208.67.222.222", "208.67.222.222 (OpenDNS)") o:value("208.67.222.222", "208.67.222.222 (OpenDNS)")
@ -36,7 +36,7 @@ index de67f1c..463bdff 100644
o:depends({dns_mode = "dns2socks"}) o:depends({dns_mode = "dns2socks"})
o:depends({dns_mode = "tcp"}) o:depends({dns_mode = "tcp"})
o:depends({dns_mode = "udp"}) o:depends({dns_mode = "udp"})
@@ -591,7 +597,7 @@ if api.is_finded("smartdns") then @@ -592,7 +598,7 @@ if api.is_finded("smartdns") then
end end
o = s:taboption("DNS", Flag, "dns_redirect", translate("DNS Redirect"), translate("Force special DNS server to need proxy devices.")) o = s:taboption("DNS", Flag, "dns_redirect", translate("DNS Redirect"), translate("Force special DNS server to need proxy devices."))