encode and decode bittorrent peer wire protocol messages with elixir
Elixir
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config Initial commit Dec 30, 2014
lib Replaced dependency from Bencodex to Bencoder Jan 11, 2015
test Added new function which encodes ltep messages Jan 11, 2015
.gitignore Initial commit Dec 30, 2014
.travis.yml Update .travis.yml May 12, 2015
LICENSE
README.md Add credits Jan 3, 2016
mix.exs Prepare v0.2 for hex Jan 11, 2015
mix.lock Prepare v0.2 for hex Jan 11, 2015

README.md

Wire

Build Status

Wire is an elixir package for decoding and encoding bittorrent peer wire protocol messages.

A message is represented in the library as a keyword list with :type: the type of the message (:keep_alive, :not_interested, etc) and the other fields of the message, e.g.

h = [type: :have, piece_index: 4]
Wire.encode [type: :interested] # <<0, 0, 0, 1, 2>>
Wire.encode [type: :bitfield, field: <<0, 4>>] # <<0, 0, 0, 3, 5, 0, 4>>

decode_messages decodes a binary containing 0 or more messages and returns a list of messages and the remaining bytes

Wire.decode_messages(<<0, 0, 0, 6, 5, 0, 2, 4, 3, 1>>)
# {[[type: :bitfield, field: <<0, 2, 4, 3, 1>>]], <<>>}
Wire.decode_messages(<< 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0xf, 5 >>)
# {[[type: :keep_alive], [type: :interested]], <<0, 0, 0, 0xf, 5>>})

Install

Add to your mix.exs deps

{:wire, "~> 0.2.0"}

Development

Built and maintained by Alexander Ivanov, with substantial contributions by Florian Adamsky

LICENSE

MIT

Copyright

Copyright (c) 2014-2015 Alexander Ivanov. See LICENSE for further details