promotional bannermobile promotional banner

Kanhe

A Fabric mod that asks for a masked join password before connecting, verified server-side.

Kanhe — Minecraft Fabric Join Password Mod

A functional Fabric mod: before joining a server, it pops up a prompt requiring a password (the password field is masked, showing all input as *). The server validates it, and admins can reset the password at any time. The format of random passwords (digits / letters / mixed) and length (default 6) are customizable, and you can also manually specify any password.

  • Both client and server must install this mod (the same jar).
  • Does not depend on Fabric API, only Fabric Loader.
  • Requires Java 25.

The name comes from the Ming dynasty credential “kanhe” (勘合) used for match verification: it only takes effect when the two halves match, the same idea as the _id match check here.

Supported Versions

Minecraft Fabric Loader Mod Version Download
26.4-snapshot-3 0.19.5 1.1.0 kanhe-fabric-1.1.0+26.4-snapshot-3.jar
26.4-snapshot-2 0.19.5 1.1.0 kanhe-fabric-1.1.0+26.4-snapshot-2.jar
26.4-snapshot-1 0.19.5 1.1.0 kanhe-fabric-1.1.0+26.4-snapshot-1.jar

1. Implementation Principle

This mod reuses vanilla’s “server address query parameter” mechanism to carry the password. The rest (prompt, validation, reset, stealth) is implemented by this mod:

Part Source
How the password is transmitted over the network (the ?_id=xxxxxx query parameter in the server address, minecraft:intent packet) Vanilla mechanism (server address ?_id= query parameter), reused directly; no new protocol was invented
Official password validation (allowed-connection-ids in server.properties, compares _id in DedicatedServer.acceptsConnection) Official has it, but it can only be hardcoded in server.properties, requires a restart after changing, and is completely ineffective for “Open to LAN” worlds
Pre-join prompt, masked input, remember password per server, re-prompt after wrong password Implemented by this mod (Mixin into ConnectScreen.startConnecting)
Random password generation (digits / letters / mixed), saving, runtime reset, format and length adjustment, /kanhe command Implemented by this mod (Mixin into ServerHandshakePacketListenerImpl.handleIntention + Commands constructor)
LAN (integrated server) is also password-protected; connections without a password are silently rejected (the server appears as if it “does not exist at all”) Implemented by this mod; vanilla mechanism cannot do this

In one sentence: the transmission channel follows vanilla _id, while the full password lifecycle (generate → prompt input → match validation → reset → external stealth) is implemented by this mod.


2. Installation

Client

Place the jar (choose the one matching your game version from the table above) into:

  • Version isolation disabled: .minecraft/mods/
  • Version isolation enabled: .minecraft/versions/<version name>/mods/

Server (Fabric Server)

Place it into the server’s mods/ directory and restart the server.

Requires Fabric Loader 0.19.5.


3. Usage

Players

  1. In Multiplayer, enter IP:port normally and click “Join Server”.
  2. The Server Password screen appears (title, server name, prompt, password input field, remember password checkbox, Join/Cancel buttons).
  3. Enter the password given by the admin (input is displayed as *), then press Enter or click “Join Server”.
  4. The password field always displays *; you can see the number of characters entered, but not the content.
  5. If the password is wrong, you return to this screen with a reason; if “Remember password” is checked, it will be auto-filled next time (it still prompts; just press Enter).

For servers without any password: leave it blank and join directly. If the address already contains ?_id=xxxxxx (or xxxxxx@IP), the mod will not prompt and will connect as-is.

Admin Commands (requires OP / permission level GameMaster or above)

The command name is /kanhe (only this command name since 1.0.0).

/kanhe help                List all usages (same as just entering `/kanhe`)
/kanhe show                View current password, random password format and length, enabled state
/kanhe reset               Generate a new random password using the current random format and length (takes effect immediately, no restart needed)
/kanhe set <password>      Manually specify password (1–64 visible characters; does not change random format or length)
/kanhe length <length>     Change random password length (4–32) and generate a new password
/kanhe mode <mode>         Change random password format and generate a new password (digits / letters lowercase / mixed lowercase letters + digits)
/kanhe on                  Enable protection
/kanhe off                 Disable protection (anyone can join after disabling)

After reset, the old password immediately becomes invalid. The command also prints the new password to the server console (English fallback text is shown when the console has no language file).

Config Files

File Purpose
Server <server directory>/config/kanhe.json enabled (switch), code (current password), mode (random password format: digits / letters / mixed), length (random password length, default 6, range 4–32), logCode (whether to print the password in logs)
LAN world <.minecraft>/config/kanhe.json Same as above; applies to the integrated server for “Open to LAN”
Client <.minecraft>/config/kanhe-client.json promptAlways (whether to still prompt when the password is remembered, default true), rememberByDefault, passwords (passwords remembered by server address)

On first launch, a random password is generated according to the configured format and length (default 6 digits), written to the config, and printed in the log: Server password is 123456 - players enter it in the join password prompt


4. Behavior Details

  • Connections without a password (including server list ping): silently disconnect like vanilla, returning no status, so when outsiders scan the port the server looks “dead” and no server information is leaked.
  • Logins with a wrong password: explicitly told “wrong password” (because the other party already knows the server exists); the client mod uses this to re-open the password prompt.
  • The world host (singleplayer/LAN host) is not blocked: the host uses an in-memory connection and bypasses handshake validation.
  • LAN guests are blocked, so friends playing together also need this mod.
  • Random passwords support three formats: digits (6 digits ≈ 1 million combinations), lowercase letters (6 chars ≈ 300 million combinations), lowercase letters + digits (6 chars ≈ 2.2 billion combinations); use /kanhe length to change length, range 4–32. Letters are lowercase only (the password field is masked; if it were case-sensitive, typos would be invisible). For manual set, max 64 visible characters (no spaces). It is recommended to use this with online-mode authentication/whitelist; if the password is leaked or brute-forced, just run /kanhe reset to change it.

5. Verification Performed (Tested During Development)

Server: Fabric 0.19.5 dedicated server (offline mode, port 25566); logs show Loading 5 mods: ... kanhe 1.0.0, Mappings not present! (confirms unobfuscated).

Raw Minecraft handshake probes (one status ping each without/with/wrong _id):

Case Result
status ping without _id closed without data (silently rejected; server invisible)
with correct _id status ok {"description":"Kanhe test server", ...}
with wrong _id closed without data

Verifying admin commands via RCON:

> kanhe show     -> Server password: 123456 (enabled)
> kanhe reset    -> New server password: 654321
old password 123456 probe again -> closed without data
new password 654321 probe -> status ok

Client: direct-connected to the server with an offline account; logs appeared in order:

[Render thread/INFO]: Asking for the join password of 127.0.0.1:25566
[Render thread/INFO]: Connecting to 127.0.0.1:25566 with a 6 digit join password

Server:

[Server thread/INFO]: Dev[/127.0.0.1:6969] logged in with entity id 1 at (9.5, -60.0, 0.5)
[Server thread/INFO]: System chat: Dev joined the game

That is: prompt → masked password input → validation passed → successfully joined the server.


Kanhe Team

profile avatar
  • 1
    Projects
  • 17
    Downloads