class Mud::Net::Telnet

Overview

A Telnet protocol manager (RFC 854).

The game implementation assumes a few things about a client connection:

In order to guarantee these assumptions hold, when we open a new Telnet connection we negotiate the following options:

Additionally the interface is intended to be used with Line-editing on the client side such that the server receives content a line at a time. To guarantee this we try to negotiate (but don't require):

If during initial negotiations any of these options are rejected, then the client is informed of the incompability and the connection is closed. Otherwise we begin sub-negotiations to check for the right terminal type and line-editing configuration.

Once all the configuration is complete the game can start to talk to the client, safe in the above assumptions.

The implementation below has been tested against the following Telnet client programs:

Defined in:

net/telnet.cr

Constant Summary

BRK = 243_u8
BT = 0_u8
DO = 253_u8
DONT = 254_u8
IAC = 255_u8
IP = 244_u8
LM = 34_u8
SB = 250_u8
SE = 240_u8
TERMS = ["XTERM", "ANSI"]

Accepted terminal types

TT = 24_u8
WILL = 251_u8
WONT = 252_u8

Constructors

Instance Method Summary

Constructor Detail

def self.new(channel : Channel(String)) #

[View source]

Instance Method Detail

def command(b) #

Interprets input byte as part of a command.


[View source]
def data(b, str) #

Interprets input byte as data.


[View source]
def negotiate #

Responds to Telnet negotiations.


[View source]
def negotiate_bt(option) #

Negotiates the binary transmission option.


[View source]
def negotiate_lm(option) #

Attempts to negotiate the linemode option.


[View source]
def negotiate_tt(option) #

Negotiates the terminal type option.


[View source]
def negotiated? #

Returns whether all prerequisite negotiations have succeeded?


[View source]
def parse?(buf : Bytes) : Array(String) #

Processes bytes read from Telnet stream.


[View source]
def subnegotiation(b, sub) #

Interprets input byte as part of a subnegotiation.


[View source]