telnet v0.1.0 Telnet.NewEnviron View Source
Parse NEW-ENVIRON requests and responses
Link to this section Summary
Functions
Encode a list of variables to request from the server
Parse the binary data into Elixir terms
Parse a IS packet
Parse a SEND packet
Strip the final IAC SE
Link to this section Functions
Encode a list of variables to request from the server
iex> NewEnviron.encode(:send, ["IPADDRESS"])
<<255, 250, 39, 1, 0>> <> "IPADDRESS" <> <<255, 240>>
iex> NewEnviron.encode(:is, [{"IPADDRESS", "localhost"}])
<<255, 250, 39, 0, 0>> <> "IPADDRESS" <> <<1>> <> "localhost" <> <<255, 240>>
iex> NewEnviron.encode(:is, [])
<<255, 250, 39, 0, 255, 240>>
Parse the binary data into Elixir terms
iex> NewEnviron.parse(<<255, 250, 39, 1, 0>> <> "IPADDRESS" <> <<3>> <> "OTHER" <> <<255, 240>>)
{:send, ["IPADDRESS", "OTHER"]}
iex> NewEnviron.parse(<<255, 250, 39, 0, 0>> <> "IPADDRESS" <> <<1>> <> "localhost" <> <<255, 240>>)
{:is, [{"IPADDRESS", "localhost"}]}
Link to this function
parse_is(data, buffer_type \\ :var, buffer_var \\ "", buffer_val \\ "", stack \\ [])
View SourceParse a IS packet
iex> NewEnviron.parse_is(<<0>> <> "IPADDRESS" <> <<1>> <> "localhost")
[{"IPADDRESS", "localhost"}]
iex> NewEnviron.parse_is(<<0>> <> "IPADDRESS" <> <<3>> <> "OTHER")
[{"IPADDRESS", ""}, {"OTHER", ""}]
Parse a SEND packet
iex> NewEnviron.parse_send(<<0>> <> "IPADDRESS" <> <<3>> <> "OTHER")
["IPADDRESS", "OTHER"]
iex> NewEnviron.parse_send(<<3>> <> "IPADDRESS" <> <<0>> <> "OTHER")
["IPADDRESS", "OTHER"]
iex> NewEnviron.parse_send(<<0>>)
[]
iex> NewEnviron.parse_send(<<1>>)
[]
iex> NewEnviron.parse_send(<<0, 1>>)
[]
Strip the final IAC SE