DhtEndpoint

class DhtEndpoint(val address: ByteArray, val port: Int)

A network endpoint (address + UDP/TCP port) as it appears inside DHT messages: the pure-Kotlin stand-in for the udp::endpoint / tcp::endpoint that libtorrent serialises with aux::write_endpoint / aux::read_v4_endpoint (include/libtorrent/socket_io.hpp).

libtorrent's compact endpoint form is the address in network byte order (4 bytes for IPv4, 16 for IPv6) immediately followed by the 16-bit port, big-endian. That is exactly 6 bytes for v4 and 18 for v6. See encode / decodeV4 / decodeV6.

KiteTorrent has no socket types in commonMain, and PeerAddress exposes only parseOrNull (no raw-bytes constructor), so this type owns the raw address bytes itself. toPeerAddress bridges to PeerAddress when the richer predicates (locality, ordering) are needed.

Constructors

Link copied to clipboard
constructor(address: ByteArray, port: Int)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

the address in network byte order: 4 bytes (IPv4) or 16 (IPv6).

Link copied to clipboard

The compact byte width of this endpoint: 6 for IPv4, 18 for IPv6.

Link copied to clipboard

True if this endpoint carries an IPv4 (4-byte) address.

Link copied to clipboard

True if this endpoint carries an IPv6 (16-byte) address.

Link copied to clipboard
val port: Int

the 16-bit port (0..65535).

Functions

Link copied to clipboard

The address rendered as an IPv4 dotted-quad or IPv6 colon-hex literal.

Link copied to clipboard

This endpoint's compact form as a fresh byte array (6 or 18 bytes).

Link copied to clipboard

Append this endpoint's compact form (address bytes then big-endian port) to out: a port of aux::write_endpoint.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

The address as a PeerAddress (via its dotted-quad / colon-hex literal), or null if the bytes don't round-trip through PeerAddress.parseOrNull (should never happen for well-formed 4/16-byte addresses).

Link copied to clipboard
open override fun toString(): String