[修复] 更新 OpenResty 模板和 Lua 逻辑以增强可读性和稳定性

This commit is contained in:
ryan
2026-05-31 21:49:43 +08:00
parent 796bf1c22f
commit 174198c283
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -50,7 +50,7 @@ local function load_config()
end
local function list_contains(items, value)
if not items or not value or value == "" then
if not items or type(items) ~= "table" or not value or value == "" then
return false
end
for _, item in ipairs(items) do
@@ -95,7 +95,7 @@ local function ipv4_in_cidr(ip, cidr)
end
local function ip_matches(items, ip)
if not items or not ip or ip == "" then
if not items or type(items) ~= "table" or not ip or ip == "" then
return false
end
for _, item in ipairs(items) do
@@ -196,7 +196,7 @@ end
local country = nil
for _, group in ipairs(groups) do
if group.country_whitelist and #group.country_whitelist > 0 then
if type(group.country_whitelist) == "table" and #group.country_whitelist > 0 then
country = country or lookup_country(ip)
if list_contains(group.country_whitelist, country) then
return
@@ -211,7 +211,7 @@ for _, group in ipairs(groups) do
end
for _, group in ipairs(groups) do
if group.country_blacklist and #group.country_blacklist > 0 then
if type(group.country_blacklist) == "table" and #group.country_blacklist > 0 then
country = country or lookup_country(ip)
if list_contains(group.country_blacklist, country) then
return exit_with_group(group)