moo.shell.iac
IAC (telnet subnegotiation) parser, encoder, and per-session negotiator.
DjangoMOO speaks SSH, not telnet. This module is the in-band channel that MUD-client protocols (GMCP, MSSP, MTTS, MSP, …) ride on top of. Clients that connect via sshelnet get raw 0xFF-prefixed IAC sequences passed through transparently.
Scope: just the IAC framing layer plus the MUD-accessibility protocols listed in issue #16. We do not implement the wider telnet spec (NAWS, ECHO, SGA, line-mode, etc.).
Byte plumbing
asyncssh channels default to UTF-8 encoding in both directions. 0xFF is
invalid UTF-8, so the SSH server reconfigures the channel to encoding=None
(bytes mode) on connect and handles text encoding itself: outbound Rich/
prompt_toolkit strings are UTF-8 encoded in the shell layer before reaching
_chan.write, and inbound bytes are decoded after the IAC parser strips
any subnegotiation frames.
Functions
|
Server reply to a client CHARSET REQUEST. |
|
Server-initiated CHARSET REQUEST subnegotiation. |
|
Encode IAC WILL/WONT/DO/DONT <opt>. |
|
Encode a GMCP subnegotiation frame for the given module name and data. |
|
Encode an MSSP response with the supplied name/value pairs. |
|
Encode IAC SB <opt> <payload> IAC SE, doubling any 0xFF in payload. |
Encode the server's request for the next TTYPE value. |
|
|
Heuristic: does this TTYPE name look like a real MUD client? |
|
|
|
Return an inline MSP sound marker for the given filename. |
|
Inverse of encode_gmcp — returns the (module, data_or_None) tuple from a GMCP frame payload. |
|
Parse a third-stage MTTS response — the integer bitfield following the MTTS prefix. |
|
Parse the client's |
Classes
|
Per-session capability state and outbound command queue. |
Byte-feed state machine for IAC sequences. |