mldht v0.0.1 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.
Summary
Types
A binary which contains the infohash of a torrent. An infohash is a SHA1 encoded hex sum which identifies a torrent
A non negative integer (0—65565) which represents a TCP port number
Functions
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
Types
Functions
Specs
search(infohash, (... -> any)) :: atom
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" ## Ubuntu 15.04
|> Base.decode16!
|> MlDHT.search(fn(node) ->
{ip, port} = node
IO.puts "ip: #{inpsect ip} port: #{port}"
end)
Specs
search_announce(infohash, (... -> any)) :: atom
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" ## Ubuntu 15.04
|> Base.decode16!
|> MlDHT.search_announce(fn(node) ->
{ip, port} = node
IO.puts "ip: #{inspect ip} port: #{port}"
end)
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)