effusion v0.2.0 Effusion.THP behaviour View Source

Behavior defining the contract of the Tracker HTTP Protocol.

Link to this section Summary

Types

A peer returned by a tracker when it was called with the compact option set.

A peer returned by a tracker.

Optional tracker parameters

A successful response from from a tracker.

Link to this section Types

Link to this type

compact_peer()

View Source
compact_peer() :: %{ip: :inet.ip4_address(), port: :inet.port_number()}

A peer returned by a tracker when it was called with the compact option set.

A peer returned by a tracker.

Link to this type

tracker_opts()

View Source
tracker_opts() :: [
  compact: 0 | 1,
  event: :started | :stopped | :completed | :interval,
  ip: :inet.ip_address(),
  key: String.t(),
  no_peer_id: 0 | 1,
  numwant: non_neg_integer(),
  trackerid: String.t()
]

Optional tracker parameters

Link to this type

tracker_response()

View Source
tracker_response() :: %{
  interval: pos_integer(),
  peers: [peer()] | [compact_peer()],
  trackerid: String.t()
}

A successful response from from a tracker.

Link to this section Callbacks

Link to this callback

announce(tracker_url, peer_host, peer_port, peer_id, info_hash, uploaded, downloaded, left, opts)

View Source
announce(
  tracker_url :: String.t() | :unicode.unicode_binary(),
  peer_host :: :inet.hostname() | :inet.ip_address(),
  peer_port :: :inet.port_number(),
  peer_id :: Effusion.peer_id(),
  info_hash :: Effusion.info_hash(),
  uploaded :: non_neg_integer(),
  downloaded :: non_neg_integer(),
  left :: non_neg_integer(),
  opts :: tracker_opts()
) :: {:ok, tracker_response()} | {:error, any()}

Announce an event to the given tracker.