From 9a0719f17ec43dfb3f73dbfe09277dba666429ee Mon Sep 17 00:00:00 2001 From: actions Date: Fri, 31 May 2024 15:00:05 +0800 Subject: [PATCH] luci-app-passwall: sync upstream last commit: https://github.com/xiaorouji/openwrt-passwall/commit/19e76cdcf26d50240550ffde615e0fd60f8061b2 --- .../luasrc/model/cbi/passwall/client/shunt_rules.lua | 11 +++++++---- luci-app-passwall/luasrc/passwall/util_xray.lua | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/shunt_rules.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/shunt_rules.lua index ba7735e6e..a5dd640dd 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/shunt_rules.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/shunt_rules.lua @@ -104,11 +104,13 @@ domain_list.rows = 10 domain_list.wrap = "off" domain_list.validate = function(self, value) 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 local flag = 1 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 elseif host:find("domain:.") and host:find("domain:.") == 1 then tmp_host = host:gsub("domain:", "") @@ -141,10 +143,11 @@ ip_list.rows = 10 ip_list.wrap = "off" ip_list.validate = function(self, value) 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) for index, ipmask in ipairs(ipmasks) do - if ipmask:find("geoip:") and ipmask:find("geoip:") == 1 then - elseif ipmask:find("ext:") and ipmask:find("ext:") == 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 and not ipmask:find("%s") then elseif ipmask:find("#") and ipmask:find("#") == 1 then else if not (datatypes.ipmask4(ipmask) or datatypes.ipmask6(ipmask)) then diff --git a/luci-app-passwall/luasrc/passwall/util_xray.lua b/luci-app-passwall/luasrc/passwall/util_xray.lua index a0a6f0364..f80c0d64d 100644 --- a/luci-app-passwall/luasrc/passwall/util_xray.lua +++ b/luci-app-passwall/luasrc/passwall/util_xray.lua @@ -947,6 +947,7 @@ function gen_config(var) if w:find("#") == 1 then return end table.insert(domains, w) end) + if #domains == 0 then domains = nil end end local ip = nil if e.ip_list then @@ -955,6 +956,7 @@ function gen_config(var) if w:find("#") == 1 then return end table.insert(ip, w) end) + if #ip == 0 then ip = nil end end local source = nil if e.source then