forked from minetest-mods/xban2
Missing record on creating new in find_entry. Fix for access logic (#30)
Access logic was flawed because if a name existed that was not banned, the IP was not checked for a ban.
This commit is contained in:
23
init.lua
23
init.lua
@@ -67,7 +67,11 @@ function xban.find_entry(key, create)
|
||||
end
|
||||
end
|
||||
if create then
|
||||
local e = { names = { [key] = true }, bans = {} }
|
||||
local e = {
|
||||
names = { [key]=true },
|
||||
banned = false,
|
||||
record = { },
|
||||
}
|
||||
table.insert(xban.db, e)
|
||||
return e, #xban.db
|
||||
end
|
||||
@@ -199,13 +203,16 @@ end
|
||||
minetest.register_on_prejoinplayer(function(name, ip)
|
||||
local wl = db.whitelist or {}
|
||||
if wl[name] or wl[ip] then return end
|
||||
local e = xban.find_entry(name) or xban.find_entry(ip)
|
||||
if not e then return end
|
||||
if e.banned then
|
||||
local date = (e.expires and os.date("%c", e.expires)
|
||||
or "the end of time")
|
||||
return ("Banned: Expires: %s, Reason: %s"):format(
|
||||
date, e.reason)
|
||||
|
||||
local e = xban.find_entry(name)
|
||||
if not e or not e.banned then
|
||||
e = ip and xban.find_entry(ip)
|
||||
end
|
||||
|
||||
if e and e.banned then
|
||||
local date = e.expires and os.date("%c", e.expires) or "the end of time"
|
||||
local reason = e.reason or "No reason given"
|
||||
return ("Banned: Expires: %s, Reason: %s"):format(date, reason)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user