Skip to content

Enforce whitelist and add command - #3467

Open
yel0h wants to merge 5 commits into
PixelGuys:masterfrom
yel0h:whitelist-command
Open

Enforce whitelist and add command#3467
yel0h wants to merge 5 commits into
PixelGuys:masterfrom
yel0h:whitelist-command

Conversation

@yel0h

@yel0h yel0h commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Enforces the player whitelist during the connection handshake and adds a /whitelist command to manage it.

After a connecting player's key is resolved, the server checks players.isAllowedToJoin when world.settings.whitelistEnabled is set, rejecting the connection with error.NotWhitelisted.

Command syntax: /whitelist <add/block> <keyType>:<base64Key> or /whitelist <add/block> @<playerIndex>

Also removes error logging for error.NotWhitelisted since it's expected to reject and already logs the reason right after rejection.

Closes #2566

@Wunka Wunka moved this to High Priority in PRs to review Aug 4, 2026

@Wunka Wunka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for continuing with this!

Comment thread src/network/protocols.zig Outdated
const keys = zon.getChild("keys");
try conn.user.?.identifyFromKeysAndName(name, keys);

if (main.server.world.?.settings.whitelistEnabled and !main.server.players.isAllowedToJoin(conn.user.?.newKeyString.?)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't like this. In my mind this can perfectly work in sync with a ban system (blocked = banned)
I would suggest to go in the direction I went with permissions. Instead of returning in isAllowedToJoin a bool return an enum: {allowed, neutral, blocked} neutral would then be the case where you need to look if whitelist is enabled

Comment thread src/server/command/whitelist.zig Outdated
.alreadyAllowed => source.sendMessage("#ff0000{s}§#ff0000 is already on the whitelist", .{key}),
},
.block => switch (players.block(key)) {
.blocked => source.sendMessage("#00ff00Blocked {s}§#00ff00 from connecting", .{key}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we go by the principle that blocked = ban then I would suggest to also kick the player here

Comment thread src/server/command/whitelist.zig Outdated
}
}

const KeyString = struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In general we put these kinds of helper in command.zig I can already imagine there being a command to for example update the key where this would help

@yel0h

yel0h commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

True, it does make more sense to treat an explicit block as a ban

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

Labels

None yet

Projects

Status: High Priority

Development

Successfully merging this pull request may close these issues.

Player whitelist

2 participants