Skip to content

fix(telnet): stop Mudlet masking all input for the whole session#632

Closed
MorquinDevlar wants to merge 1 commit into
masterfrom
fix/mudlet-echo-masking
Closed

fix(telnet): stop Mudlet masking all input for the whole session#632
MorquinDevlar wants to merge 1 commit into
masterfrom
fix/mudlet-echo-masking

Conversation

@MorquinDevlar

@MorquinDevlar MorquinDevlar commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Problem

When connecting with Mudlet (raw telnet, not the web client), the input line is masked (hidden) for the entire session - the username prompt, every command, everything - not just password prompts.

Root cause

On connect, handleTelnetConnection() unconditionally sent IAC WILL ECHO to every telnet client and never withdrew it. GoMud runs in character-at-a-time mode and does server-side echo (echoing each typed character itself, emitting mask characters for passwords). That is correct for raw character-mode telnet clients that rely on the server to echo.

Mudlet, however, echoes locally and interprets the telnet ECHO option purely as a password-masking hint:

  • IAC WILL ECHO -> hide/mask the input line
  • IAC WONT ECHO -> show the input line

Because the server asserted WILL ECHO once at connect and never sent WONT ECHO (its masking is done at the application layer), Mudlet stayed in "masked" mode permanently.

Fix

Detect the client type at connect and branch the echo behavior. Raw-telnet and web-client behavior are unchanged; the new behavior applies only to local-echo (Mudlet) clients.

State Mudlet baseline During password prompt After password prompt
Server sends IAC WONT ECHO IAC WILL ECHO IAC WONT ECHO
Mudlet input visible (local) masked visible again

Detection (the timing problem)

GoMud does not know a client is Mudlet at the moment it must choose the connect-time echo baseline (GMCP detection arrives too late). This adds a short, synchronous MNES NEW-ENVIRON probe before the first prompt: the server requests CLIENT_NAME/CLIENT_VERSION, and Mudlet replies CLIENT_NAME=Mudlet. The probe is bounded (200ms per read, 2s overall); a client that ignores NEW-ENVIRON falls back to non-Mudlet and still logs in. AI connections skip the probe and keep the historical baseline.

Changes

  • internal/connections/clientsettings.go - add IsMudlet / DetectionComplete.
  • internal/connections/connectiondetails.go - SetReadDeadline for bounded probe reads (telnet path only).
  • internal/term/{telnet,term}.go - NEW-ENVIRON sub-negotiation codes, request/response matchers, and a TelnetRequestMNESVars helper.
  • internal/inputhandlers/term_iac.go - negotiate NEW-ENVIRON and record IsMudlet from CLIENT_NAME (+ unit test for the response parser).
  • main.go - detectClientType probe and the echo-baseline branch; the login handler is now added to the chain after detection.
  • internal/inputhandlers/login_prompt_handler.go - skip server echo/mask and the Enter newline for local-echo clients; toggle WILL/WONT ECHO masking around Mudlet password steps.

Test plan

  • Mudlet: username prompt shows typed text; password prompt masked; after login all gameplay input visible. Reconnect a few times (timing).
  • New-character creation in Mudlet: new-password and verify-password steps mask; everything else visible.
  • Raw telnet (telnet/tintin++): unchanged - server echoes input, passwords masked with mask chars.
  • Web client: unchanged - TEXTMASK toggles the password field; no double echo.
  • Detection timeout: a client that ignores NEW-ENVIRON falls back to non-Mudlet within ~2s and still logs in.

Automated: make validate and go test ./... pass; added TestNewEnvironIsMudlet / TestNewEnvironResponseMatcher.

@MorquinDevlar MorquinDevlar requested a review from Volte6 as a code owner June 17, 2026 20:05
Mudlet (and other local-echo clients) treat telnet WILL ECHO as a
"mask this field" hint rather than a server-echo request. GoMud asserted
WILL ECHO unconditionally at connect and never withdrew it, so Mudlet
masked every keystroke for the entire session.

Detect the client type at connect via an MNES NEW-ENVIRON probe and
branch the echo behavior:

- Mudlet: baseline WONT ECHO (Mudlet echoes locally); the server no
  longer echoes/masks per character or emits its own newline. Password
  prompts are masked by transiently asserting WILL ECHO and withdrawing
  it (WONT ECHO) once the step validates.
- Raw telnet: unchanged - WILL ECHO baseline with server-side echo and
  mask-character passwords.
- Web client: unchanged - TEXTMASK toggling, no server-side per-char echo.

Detection is synchronous and bounded (200ms per read, 2s overall); a
client that ignores NEW-ENVIRON falls back to non-Mudlet and still logs
in. AI connections skip the probe and keep the historical baseline.

Changes:
- connections.ClientSettings: add IsMudlet / DetectionComplete.
- ConnectionDetails.SetReadDeadline for the bounded probe reads.
- term: NEW-ENVIRON sub-negotiation codes, request/response matchers,
  and a TelnetRequestMNESVars helper.
- TelnetIACHandler: negotiate NEW-ENVIRON and record IsMudlet from
  CLIENT_NAME, plus a unit test for the response parser.
- main.go: detectClientType probe and echo-baseline branch.
- login_prompt_handler: skip server echo/mask and newline for local-echo
  clients; toggle ECHO masking around Mudlet password steps.
@MorquinDevlar MorquinDevlar force-pushed the fix/mudlet-echo-masking branch from 3cce9bb to ae023bb Compare June 17, 2026 20:10

@Volte6 Volte6 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One small change request.

This is a lot of change for mudlet, with special exceptions. That's annoying. Oh well.

Comment thread internal/term/telnet.go
Comment on lines +139 to +145
TELNET_NEWENV_IS IACByte = 0 // Client -> Server: here are my variables
TELNET_NEWENV_SEND IACByte = 1 // Server -> Client: please send these variables
TELNET_NEWENV_INFO IACByte = 2 // Client -> Server: a variable changed
TELNET_NEWENV_VAR IACByte = 0 // A well-known variable name follows
TELNET_NEWENV_VALUE IACByte = 1 // A variable value follows
TELNET_NEWENV_ESC IACByte = 2 // Escape the next byte (it is data, not a code)
TELNET_NEWENV_USERVAR IACByte = 3 // A user-defined variable name follows

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These IACByte's are already defined - should be aliases:

	TELNET_NEWENV_IS      = TELNET_OPT_TXBIN
	TELNET_NEWENV_SEND    = TELNET_OPT_ECHO
	TELNET_NEWENV_INFO    = TELNET_OPT_RECONN
	TELNET_NEWENV_VAR     = TELNET_OPT_TXBIN
	TELNET_NEWENV_VALUE   = TELNET_NEWENV_SEND
	TELNET_NEWENV_ESC     = TELNET_NEWENV_INFO
	TELNET_NEWENV_USERVAR = TELNET_OPT_SUP_GO_AHD

@MorquinDevlar

Copy link
Copy Markdown
Contributor Author

Superseded by #633, re-opened from a fork (MorquinDevlar/GoMud). Closing this branch-based PR; the diff is identical.

@MorquinDevlar MorquinDevlar deleted the fix/mudlet-echo-masking branch June 17, 2026 20:25
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