Skip to content

Commit cb76bc5

Browse files
authored
Some little cleanup
1 parent b6f85de commit cb76bc5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

create_account_ban.lua

+7-7
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,23 @@ local function read_storage()
5151
end
5252

5353
local function write_storage()
54-
storage:set_string("create_account_ban.blacklist_ip", blacklist_ip and minetest.serialize(blacklist_ip) or "")
54+
storage:set_string("create_account_ban.blacklist_ip", blacklist_ip and minetest.serialize(blacklist_ip) or "")
5555
storage:set_string("create_account_ban.blacklist_asn", blacklist_asn and minetest.serialize(blacklist_asn) or "")
5656
storage:set_string("create_account_ban.active", active and "1" or "")
5757
storage:set_int("create_account_ban.logging", logging)
5858
end
5959

60-
local function validate(name, ip, key, options)
61-
if options.pattern then
62-
return ip:find(key) == nil
60+
local function match_values(a, b, options)
61+
if type(options) == "table" and options.pattern then
62+
return a:find(b) ~= nil
6363
end
64-
return ip ~= key
64+
return a == b
6565
end
6666

6767
minetest.register_on_prejoinplayer(function(name, ip)
6868
if active and blacklist_ip and not minetest.get_auth_handler().get_auth(name) then
69-
for key, options in pairs(blacklist_ip) do
70-
if not validate(name, ip, key, options) then
69+
for ip_pattern, options in pairs(blacklist_ip) do
70+
if match_values(ip, ip_pattern, options) then
7171
-- Account creation blocked by blacklisted IP address
7272
if has_beerchat then
7373
local msg = "Blocked new account " .. name .. " from " .. ip

0 commit comments

Comments
 (0)