Package-level declarations

Types

Link copied to clipboard
class AnnounceEntry(val url: String, val tier: Int = 0, var fails: Int = 0, var isWorking: Boolean = true, var nextAnnounceEpochSecs: Long = 0, var minAnnounceEpochSecs: Long = 0, var lastEvent: TrackerEvent = TrackerEvent.NONE, var completeSent: Boolean = false, var startSent: Boolean = false, var trackerId: String = "")

Per-URL announce bookkeeping. This is the KiteTorrent port of the live state libtorrent carries in aux::announce_entry and aux::announce_infohash (include/libtorrent/aux_/announce_entry.hpp). The session module owns the announce loop and tier logic; this struct is the mutable state it threads per tracker URL so the loop can decide when to (re-)announce and what to send.

Link copied to clipboard
data class AnnounceRequest(val infoHash: Sha1Hash, val peerId: PeerId, val port: Int, val uploaded: Long, val downloaded: Long, val left: Long, val event: TrackerEvent = TrackerEvent.NONE, val numWant: Int = -1, val key: Int = 0, val ip: Int = 0, val trackerId: String = "")

The parameters of a tracker announce, independent of whether it will be sent over HTTP or UDP. Mirrors the announce-relevant subset of libtorrent's tracker_request.

Link copied to clipboard
data class AnnounceResponse(val interval: Int, val leechers: Int, val seeders: Int, val peers: List<PeerEndpoint>, val minInterval: Int = DEFAULT_MIN_INTERVAL, val trackerId: String = "")

A tracker's response to an announce. This is the announce-relevant subset of libtorrent's tracker_response.

Link copied to clipboard
class HttpTracker(client: HttpClient, maxResponseBytes: Int = DEFAULT_MAX_RESPONSE_BYTES, network: NetworkRuntime? = null)

HTTP(S) tracker client, the network half of libtorrent's http_tracker_connection. All the protocol logic (building the announce URL with percent-encoded binary info-hash/peer-id, parsing the bencoded response incl. BEP-23 compact peers) lives in the pure, tested HttpTrackerCodec; this class is just the ktor-client GET around it.

Link copied to clipboard
data class PeerEndpoint(val host: String, val port: Int)

A single peer endpoint returned by a tracker: an IP address (in dotted-quad or colon-hex string form) and a TCP port. This is the flattened equivalent of libtorrent's ipv4_peer_entry / ipv6_peer_entry (peer.hpp); KiteTorrent's peer layer keeps addresses as host strings (see peer.PeerAddress), so the compact 6-byte (v4) / 18-byte (v6) tracker encodings are decoded into strings here.

Link copied to clipboard
data class ScrapeResponse(val seeders: Int, val completed: Int, val leechers: Int)

A tracker's response to a scrape: the per-info-hash swarm statistics. It ports the arguments libtorrent passes to request_callback::tracker_scrape_response (complete, incomplete, downloaded, downloaders).

Link copied to clipboard

The exponential failure back-off libtorrent applies between failed announces, ported from announce_infohash::failed (src/announce_entry.cpp). Exposed as a pure helper so the session's announce loop can compute the next-announce instant without duplicating the formula. The loop owns when to call it; this just does the arithmetic.

Link copied to clipboard

The announce event, porting libtorrent's enum class event_t (tracker_manager.hpp).

Link copied to clipboard
class TrackerFailure(val reason: String) : Exception

Thrown when a tracker returns a failure reason member (BEP-3), the typed counterpart of libtorrent setting resp.failure_reason and raising the errors::tracker_failure code. Carries both the human-readable reason text the tracker sent and the corresponding error code (LibtorrentError.TRACKER_FAILURE), so a caller can surface the message or branch on the code uniformly with the plain TorrentExceptions this codec also throws.

Link copied to clipboard
object TrackerKey

The per-torrent &key= value libtorrent threads into every announce (torrent::tracker_key()), a stable 32-bit identifier the tracker uses to recognise us across IP changes. libtorrent derives it deterministically from object addresses; that is impossible (and pointless) on KMP, so we generate a random 32-bit value once per torrent and reuse it. The wire semantics are identical: the same opaque key travels on every announce for this torrent. The old default of 0 is replaced by generate.

Link copied to clipboard
class UdpTracker(udp: UdpSocket, random: Random = Random.Default, maxAttempts: Int = 4, baseTimeoutMs: Long, connectionIdTtlMs: Long, nowMs: () -> Long = { 0L })

A BEP-15 UDP tracker client: the live half of libtorrent's udp_tracker_connection (src/udp_tracker_connection.cpp), driven over the proven UdpSocket. The fixed-layout packet build/parse lives in UdpTrackerCodec; this class owns the transaction: the mandatory two-step connect→announce handshake, the random transaction ids, connection-id caching, and the "ignore datagrams that aren't ours" filtering.