class Telnet

Overview

Telnet for crystal lang

Defined in:

telnet.cr

Constant Summary

ABORT = 238_u8
AO = 245_u8
AYT = 246_u8
AYT_RESPONSE = "nobody here but us pigeons".to_slice
BREAK = 243_u8
CR = 13_u8
DM = 242_u8
DO = 253_u8
DONT = 254_u8
EC = 247_u8
EL = 248_u8
EOF = 236_u8
EOL = "\r\n".to_slice
EOR = 239_u8
GA = 249_u8
IAC = 255_u8
IP = 244_u8
LF = 10_u8
NOP = 241_u8
NULL = 0_u8
OPT_3270REGIME = 29_u8
OPT_AUTHENTICATION = 37_u8
OPT_BINARY = 0_u8
OPT_BM = 19_u8
OPT_DET = 20_u8
OPT_ECHO = 1_u8
OPT_ENCRYPT = 38_u8
OPT_EOR = 25_u8
OPT_EXOPL = 255_u8
OPT_LFLOW = 33_u8
OPT_LINEMODE = 34_u8
OPT_LOGOUT = 18_u8
OPT_NAMS = 4_u8
OPT_NAOCRD = 10_u8
OPT_NAOFFD = 13_u8
OPT_NAOHTD = 12_u8
OPT_NAOHTS = 11_u8
OPT_NAOL = 8_u8
OPT_NAOLFD = 16_u8
OPT_NAOP = 9_u8
OPT_NAOVTD = 15_u8
OPT_NAOVTS = 14_u8
OPT_NAWS = 31_u8
OPT_NEW_ENVIRON = 39_u8
OPT_OLD_ENVIRON = 36_u8
OPT_OUTMRK = 27_u8
OPT_RCP = 2_u8
OPT_RCTE = 7_u8
OPT_SGA = 3_u8
OPT_SNDLOC = 23_u8
OPT_STATUS = 5_u8
OPT_SUPDUP = 21_u8
OPT_SUPDUPOUTPUT = 22_u8
OPT_TM = 6_u8
OPT_TSPEED = 32_u8
OPT_TTYLOC = 28_u8
OPT_TTYPE = 24_u8
OPT_TUID = 26_u8
OPT_X3PAD = 30_u8
OPT_XASCII = 17_u8
OPT_XDISPLOC = 35_u8
SB = 250_u8
SE = 240_u8
SUSP = 237_u8
SYNCH = 242_u8
WILL = 251_u8
WONT = 252_u8

Constructors

Instance Method Summary

Constructor Detail

def self.new(&write : Bytes -> Nil) #

[View source]

Instance Method Detail

def binary_mode : Bool #

[View source]
def buffer(data) : Bytes #

Buffering here deals with "un-escaping" according to the TELNET protocol. In the TELNET protocol byte value 255 is special. The TELNET protocol calls byte value 255: "IAC". Which is short for "interpret as command". The TELNET protocol also has a distinction between 'data' and 'commands'.

If a byte with value 255 (=IAC) appears in the data, then it must be escaped. Escaping byte value 255 (=IAC) in the data is done by putting 2 of them in a row. So, for example: Bytes[255] -> Bytes[255, 255] Or, for a more complete example, if we started with the following: Bytes[1, 55, 2, 155, 3, 255, 4, 40, 255, 30, 20] ... TELNET escaping would produce the following: Bytes[1, 55, 2, 155, 3, 255, 255, 4, 40, 255, 255, 30, 20] (Notice that each "255" in the original byte array became 2 "255"s in a row.) Buffer here deals with "un-escaping". In other words, it un-does what was shown in the examples. So, for example, it does this: Bytes[255, 255] -> Bytes[255] And, for example, goes from this: Bytes[1, 55, 2, 155, 3, 255, 255, 4, 40, 255, 255, 30, 20] ... to this: Bytes[1, 55, 2, 155, 3, 255, 4, 40, 255, 30, 20]


[View source]
def buffer : Slice(UInt8) #

[View source]
def prepare(command, escape = false) #

[View source]
def suppress_go_ahead : Bool #

[View source]