luci-app-passwall: sync upstream

last commit: 19e76cdcf2
This commit is contained in:
actions 2024-05-31 15:00:05 +08:00
parent ddecd4f0cc
commit 9a0719f17e
2 changed files with 9 additions and 4 deletions

View File

@ -104,11 +104,13 @@ domain_list.rows = 10
domain_list.wrap = "off" domain_list.wrap = "off"
domain_list.validate = function(self, value) domain_list.validate = function(self, value)
local hosts= {} local hosts= {}
string.gsub(value, '[^' .. "\r\n" .. ']+', function(w) table.insert(hosts, w) end) value = value:gsub("^%s+", ""):gsub("%s+$","\n"):gsub("\r\n","\n"):gsub("[ \t]*\n[ \t]*", "\n")
string.gsub(value, "[^\r\n]+", function(w) table.insert(hosts, w) end)
for index, host in ipairs(hosts) do for index, host in ipairs(hosts) do
local flag = 1 local flag = 1
local tmp_host = host local tmp_host = host
if host:find("regexp:") and host:find("regexp:") == 1 then if not host:find("#") and host:find("%s") then
elseif host:find("regexp:") and host:find("regexp:") == 1 then
flag = 0 flag = 0
elseif host:find("domain:.") and host:find("domain:.") == 1 then elseif host:find("domain:.") and host:find("domain:.") == 1 then
tmp_host = host:gsub("domain:", "") tmp_host = host:gsub("domain:", "")
@ -141,10 +143,11 @@ ip_list.rows = 10
ip_list.wrap = "off" ip_list.wrap = "off"
ip_list.validate = function(self, value) ip_list.validate = function(self, value)
local ipmasks= {} local ipmasks= {}
value = value:gsub("^%s+", ""):gsub("%s+$","\n"):gsub("\r\n","\n"):gsub("[ \t]*\n[ \t]*", "\n")
string.gsub(value, '[^' .. "\r\n" .. ']+', function(w) table.insert(ipmasks, w) end) string.gsub(value, '[^' .. "\r\n" .. ']+', function(w) table.insert(ipmasks, w) end)
for index, ipmask in ipairs(ipmasks) do for index, ipmask in ipairs(ipmasks) do
if ipmask:find("geoip:") and ipmask:find("geoip:") == 1 then if ipmask:find("geoip:") and ipmask:find("geoip:") == 1 and not ipmask:find("%s") then
elseif ipmask:find("ext:") and ipmask:find("ext:") == 1 then elseif ipmask:find("ext:") and ipmask:find("ext:") == 1 and not ipmask:find("%s") then
elseif ipmask:find("#") and ipmask:find("#") == 1 then elseif ipmask:find("#") and ipmask:find("#") == 1 then
else else
if not (datatypes.ipmask4(ipmask) or datatypes.ipmask6(ipmask)) then if not (datatypes.ipmask4(ipmask) or datatypes.ipmask6(ipmask)) then

View File

@ -947,6 +947,7 @@ function gen_config(var)
if w:find("#") == 1 then return end if w:find("#") == 1 then return end
table.insert(domains, w) table.insert(domains, w)
end) end)
if #domains == 0 then domains = nil end
end end
local ip = nil local ip = nil
if e.ip_list then if e.ip_list then
@ -955,6 +956,7 @@ function gen_config(var)
if w:find("#") == 1 then return end if w:find("#") == 1 then return end
table.insert(ip, w) table.insert(ip, w)
end) end)
if #ip == 0 then ip = nil end
end end
local source = nil local source = nil
if e.source then if e.source then