Skip to content

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

Merged
MorquinDevlar merged 3 commits into
GoMudEngine:masterfrom
MorquinDevlar:fix/mudlet-echo-masking
Jun 18, 2026
Merged

fix(telnet): stop Mudlet masking all input for the whole session#633
MorquinDevlar merged 3 commits into
GoMudEngine:masterfrom
MorquinDevlar:fix/mudlet-echo-masking

Conversation

@MorquinDevlar

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.

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.

@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.

Small change requested

Comment thread internal/term/telnet.go Outdated
Address review feedback on PR GoMudEngine#633: the NEW-ENVIRON sub-negotiation
codes share byte values with telnet option constants already defined in
this block, so alias them instead of re-declaring literals. Values are
unchanged (IS/VAR=0, SEND/VALUE=1, INFO/ESC=2, USERVAR=3), so behavior
is identical.
@MorquinDevlar

Copy link
Copy Markdown
Contributor Author

I'll do a little more testing and alert you before merging. I want Mudlet to be able to mask password input, and while it does not show it in the main window, it's not masked on the input line in Mudlet. I have that working on my own version, so I just have to port that over.

Real-Mudlet testing showed password masking half-working: Mudlet honored
WILL ECHO (command echo suppressed) but did not put asterisks on the
input line. Aligns the connect/detection sequence with a known-working
downstream fork:

- Offer WILL EOR at connect. Mudlet prefers EOR over GA to delimit
  prompts; with SUPPRESS-GO-AHEAD set and no EOR, Mudlet has no prompt
  anchor for its input-line masking.
- Request ALL NEW-ENVIRON variables (empty SEND) instead of naming
  specific ones - broadly compatible; Mudlet returns CLIENT_NAME among
  them.
- Match the NEW-ENVIRON IS response on the 'IAC SB NEW-ENVIRON IS'
  prefix alone (tolerant of TCP segmentation / trailing bytes), and make
  the parser treat IAC as a name/value terminator so a trailing IAC SE
  never bleeds into the final variable's value.
@MorquinDevlar

Copy link
Copy Markdown
Contributor Author

Crap... looks like there is a bug in Mudlet. They don't set a default value for the DisablePasswordMasking checkbox for new profiles, so it defaults to use whatever value is in memory at the time it's run. If it's not 0x00 it defaults to checked, which completely removes the password masking options.

This I can get to randomly flip by restarting Mudlet...

It's past midnight now, so I'll leave this alone for now, and get back to it tomorrow.

The code for GoMud works like it is supposed to, so I guess we could merge, but I want to make sure I am not seeing things because I am tired before actually merging it.

@MorquinDevlar MorquinDevlar merged commit 39e4401 into GoMudEngine:master Jun 18, 2026
9 of 10 checks passed
@MorquinDevlar MorquinDevlar deleted the fix/mudlet-echo-masking branch June 18, 2026 08:37
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