parse

fun parse(payload: ByteArray): UtPex.Message?

Parse a PEX message payload (the bencoded body of the extended message, without the wire framing).

Reproduces on_extended's logic:

  • the payload must bdecode to a dict (else null);

  • dropped / dropped6 are read as compact peer lists with no flags;

  • added is paired with added.f only if the flag string has exactly one byte per peer (added.f.length == added.length / 6); otherwise the added list is skipped. Same for added6 / added6.f at 18 bytes per peer;

  • each received flag byte is masked with PexFlags.RECEIVE_MASK to strip the internal pex_lt_v2 bit.

Return

the decoded Message, or null if payload is not a bencode dict.