PexFlags

object PexFlags

The per-peer PEX flag bits, the port of the pex_* constants in libtorrent/extensions/ut_pex.hpp (referenced from ut_pex.cpp). They travel in the added.f and added6.f byte strings.

Properties

Link copied to clipboard
const val ENCRYPTION: Int = 1

0x01: peer supports (BitTorrent) encryption. pex_encryption.

Link copied to clipboard
const val HOLEPUNCH: Int = 8

0x08: peer supports the hole-punching protocol. pex_holepunch.

Link copied to clipboard
const val LT_V2: Int = 16

0x10: the internal "lt v2" marker (pex_lt_v2). libtorrent strips this from received flags with flags &= ~pex_lt_v2; it is never trusted from the wire.

Link copied to clipboard
const val RECEIVE_MASK: Int

The mask applied to a received flags byte: every bit except the internal LT_V2. parse ANDs each incoming flag with this, matching flags &= ~pex_lt_v2 in on_extended.

Link copied to clipboard
const val SEED: Int = 2

0x02: peer is a seed. pex_seed.

Link copied to clipboard
const val UTP: Int = 4

0x04: peer supports uTP. Positive-only (0 does not imply no uTP). pex_utp.

Functions

Link copied to clipboard
fun build(encryption: Boolean = false, seed: Boolean = false, utp: Boolean = false, holepunch: Boolean = false): Int

Assemble the per-peer flags byte the way ut_pex_plugin::tick does:

Link copied to clipboard
fun isEncrypted(flags: Int): Boolean

True if flags has the ENCRYPTION bit.

Link copied to clipboard
fun isSeed(flags: Int): Boolean

True if flags has the SEED bit.

Link copied to clipboard
fun isUtp(flags: Int): Boolean

True if flags has the UTP bit (positive-only: false means unknown).

Link copied to clipboard

True if flags has the HOLEPUNCH bit (positive-only: false means unknown).