effusion v0.2.0 Effusion.THP.Decode View Source

Decodes a tracker response.

Link to this section Summary

Functions

Decodes a binary containing compact peers.

Decodes a tracker peer response.

Decodes a list of peers in the non-compact representation.

Link to this section Functions

Link to this function

decode_compact_peers(bin)

View Source

Decodes a binary containing compact peers.

Examples

iex> Effusion.THP.Decode.decode_compact_peers(<<192, 168, 1, 1, 255, 255>>)
[%{port: 65_535, ip: {192, 168, 1, 1}}]

Decodes a tracker peer response.

Link to this function

decode_standard_peers(list)

View Source

Decodes a list of peers in the non-compact representation.

Examples

iex> Effusion.THP.Decode.decode_standard_peers([%{
...>   "ip" => "192.168.1.1",
...>   "port" => 65_535,
...>   "peer id" => "12345678901234567890"
...> }])
[%{ip: {192, 168, 1, 1}, port: 65_535, peer_id: "12345678901234567890"}]

iex> Effusion.THP.Decode.decode_standard_peers([%{
...>   "ip" => "fd4a:6f02:ec34:1201:0:0:0:0",
...>   "port" => 65_535,
...>   "peer id" => "12345678901234567890"
...> }])
[%{ip: {64842, 28418, 60468, 4609, 0, 0, 0, 0}, port: 65_535, peer_id: "12345678901234567890"}]

iex> Effusion.THP.Decode.decode_standard_peers([%{
...>   "ip" => "peer.example.com",
...>   "port" => 65_535,
...>   "peer id" => "12345678901234567890"
...> }])
[%{ip: "peer.example.com", port: 65_535, peer_id: "12345678901234567890"}]