telnet v0.1.0 Telnet.Options View Source

Parse telnet IAC options coming from the game

Link to this section Summary

Functions

Convert a byte to a known option, or leave as as the byte

Convert a known option back to a byte or pass through the byte

Parse options out of a binary stream

Parse binary data from a MUD into any telnet options found and known

Strip the final IAC SE from the charset

Parse sub negotiation options out of a stream

Transform IAC binary data to actionable terms

Link to this section Functions

Convert a byte to a known option, or leave as as the byte

iex> Options.byte_to_option(1)
:echo

iex> Options.byte_to_option(24)
:term_type

iex> Options.byte_to_option(34)
:line_mode

iex> Options.byte_to_option(39)
:new_environ

iex> Options.byte_to_option(42)
:charset

iex> Options.byte_to_option(70)
:mssp

iex> Options.byte_to_option(165)
:oauth

iex> Options.byte_to_option(201)
:gmcp

Convert a known option back to a byte or pass through the byte

iex> Options.option_to_byte(:echo)
1

iex> Options.option_to_byte(:term_type)
24

iex> Options.option_to_byte(:line_mode)
34

iex> Options.option_to_byte(:new_environ)
39

iex> Options.option_to_byte(:charset)
42

iex> Options.option_to_byte(:mssp)
70

iex> Options.option_to_byte(:oauth)
165

iex> Options.option_to_byte(:gmcp)
201
Link to this function

options(arg, current, stack, leftover)

View Source

Parse options out of a binary stream

Parse binary data from a MUD into any telnet options found and known

Strip the final IAC SE from the charset

Link to this function

parse_sub_negotiation(data, stack \\ <<>>)

View Source

Parse sub negotiation options out of a stream

Transform IAC binary data to actionable terms

iex> Options.transform(<<255, 251, 1>>)
{:will, :echo}

iex> Options.transform(<<255, 252, 1>>)
{:wont, :echo}

iex> Options.transform(<<255, 253, 1>>)
{:do, :echo}

iex> Options.transform(<<255, 254, 1>>)
{:dont, :echo}

Returns a generic DO/WILL if the specific term is not known. For responding with the opposite command to reject.

iex> Options.transform(<<255, 251, 2>>)
{:will, 2}

iex> Options.transform(<<255, 252, 2>>)
{:wont, 2}

iex> Options.transform(<<255, 253, 2>>)
{:do, 2}

iex> Options.transform(<<255, 254, 2>>)
{:dont, 2}

Everything else is parsed as :unknown

iex> Options.transform(<<255>>)
:unknown