Skip to content

Conversation

@MCLV-pandorabox
Copy link
Contributor

Access logic was flawed because if a name existed that was not banned, the IP was not checked for a ban.
I forgot to add the records table when creating a new entry.(Fix)

Access logic was flawed because if a name existed that was not banned, the IP was not checked for a ban.
init.lua Outdated
Comment on lines 229 to 245
local wl = db.whitelist or {}
if wl[name] or wl[ip] then return end

-- Single lookups for name and IP
local e_name = xban.find_entry(name)
local e_ip = ip and xban.find_entry(ip)

if (e_name and e_name.banned) or (e_ip and e_ip.banned) then
local date =
(e_name and e_name.banned and e_name.expires and os.date("%c", e_name.expires)) or
(e_ip and e_ip.banned and e_ip.expires and os.date("%c", e_ip.expires)) or "the end of time"
local reason =
(e_name and e_name.banned and e_name.reason) or
(e_ip and e_ip.banned and e_ip.reason) or "No reason given"
minetest.kick_player(name, ("Banned: Expires: %s, Reason: %s"):format(date, reason))
return
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need the same code here? All players must first pass register_on_prejoinplayer, thus this is redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes, flawed logic in my head. no need to check that again

init.lua Outdated
Comment on lines 212 to 214
local date =
(e_name and e_name.banned and e_name.expires and os.date("%c", e_name.expires)) or
(e_ip and e_ip.banned and e_ip.expires and os.date("%c", e_ip.expires)) or "the end of time"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code duplication. Wouldn't it be simpler to use something like this? (untested)

local e = xban.find_entry(name)

if not e or not e.banned then
	-- Check if banned by IP
	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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true.

e.names[ip] = true
end
e.last_seen = os.time()
local e = xban.find_entry(name)
Copy link
Member

@SmallJoker SmallJoker Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use tabs to indent, like used in the rest of the code.

EDIT: The same goes for xban.find_entry. I did not notice that the indent style is now mixed.

end)

minetest.register_on_joinplayer(
function(player)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... no changes here? The change of indent levels makes it difficult to see differences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants