@@ -51,23 +51,23 @@ local function read_storage()
51
51
end
52
52
53
53
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 " " )
55
55
storage :set_string (" create_account_ban.blacklist_asn" , blacklist_asn and minetest .serialize (blacklist_asn ) or " " )
56
56
storage :set_string (" create_account_ban.active" , active and " 1" or " " )
57
57
storage :set_int (" create_account_ban.logging" , logging )
58
58
end
59
59
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
63
63
end
64
- return ip ~= key
64
+ return a == b
65
65
end
66
66
67
67
minetest .register_on_prejoinplayer (function (name , ip )
68
68
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
71
71
-- Account creation blocked by blacklisted IP address
72
72
if has_beerchat then
73
73
local msg = " Blocked new account " .. name .. " from " .. ip
0 commit comments