mldht v0.0.3 MlDHT
MlDHT is an Elixir package that provides a Kademlia Distributed Hash Table (DHT) implementation according to BitTorrent Enhancement Proposals (BEP) 05. This specific implementation is called "mainline" variant.
Link to this section Summary
Types
A binary which contains the infohash of a torrent. An infohash is a SHA1 encoded hex sum which identifies a torrent.
TODO
TODO
A non negative integer (0--65565) which represents a TCP port number.
Functions
This function returns the generated node_id as a bitstring.
This function returns the generated node_id encoded as a String (40 characters).
This function needs an infohash as binary and a callback function as parameter. This function uses its own routing table as a starting point to start a get_peers search for the given infohash.
This function needs an infohash as binary and callback function as
parameter. This function does the same thing as the search/2 function, except
it sends an announce message to the found peers. This function does not need a
TCP port which means the announce message sets :implied_port
to true.
This function needs an infohash as binary, a callback function as parameter, and a TCP port as integer. This function does the same thing as the search/2 function, except it sends an announce message to the found peers.
Link to this section Types
A binary which contains the infohash of a torrent. An infohash is a SHA1 encoded hex sum which identifies a torrent.
TODO
TODO
A non negative integer (0--65565) which represents a TCP port number.
Link to this section Functions
This function returns the generated node_id as a bitstring.
This function returns the generated node_id encoded as a String (40 characters).
This function needs an infohash as binary and a callback function as parameter. This function uses its own routing table as a starting point to start a get_peers search for the given infohash.
Example
iex> "3F19B149F53A50E14FC0B79926A391896EABAB6F"
|> Base.decode16!
|> MlDHT.search(fn(node) ->
{ip, port} = node
IO.puts "ip: #{inspect ip} port: #{port}"
end)
search_announce(infohash, callback)
This function needs an infohash as binary and callback function as
parameter. This function does the same thing as the search/2 function, except
it sends an announce message to the found peers. This function does not need a
TCP port which means the announce message sets :implied_port
to true.
Example
iex> "3F19B149F53A50E14FC0B79926A391896EABAB6F"
|> Base.decode16!
|> MlDHT.search_announce(fn(node) ->
{ip, port} = node
IO.puts "ip: #{inspect ip} port: #{port}"
end)
search_announce(infohash, callback, port)
This function needs an infohash as binary, a callback function as parameter, and a TCP port as integer. This function does the same thing as the search/2 function, except it sends an announce message to the found peers.
Example
iex> "3F19B149F53A50E14FC0B79926A391896EABAB6F" ## Ubuntu 15.04
|> Base.decode16!
|> MlDHT.search_announce(fn(node) ->
{ip, port} = node
IO.puts "ip: #{inspect ip} port: #{port}"
end, 6881)