Companion
Properties
Functions
Build an announce_peer query: a{id, info_hash, port, token, implied_port?, seed?, n?}. Port of the e["q"]="announce_peer" assembly in node::announce's callback.
Build an error response: {t, y:"e", e:[code, message]}. Direct port of incoming_error(entry&, char const*, int).
Build a find_node query: a{id, target}. (libtorrent issues this via refresh/bootstrap; the argument layout matches incoming_request's find_node schema.)
Build a get (BEP-44) response: r{id, token, nodes?, nodes6?, [seq, v, k, sig]}. Port of the get branch of incoming_request plus dht_storage::get_mutable_item/get_immutable_item: an immutable item adds only v; a mutable item adds seq always and v/sig/k when filled.
Build a find_node-style response: r{id, nodes?, nodes6?}. Mirrors write_nodes_entries, which writes the compact list under the protocol's nodes/nodes6 key.
Build a get_peers response: r{id, token, values?, nodes?, nodes6?}. Port of lookup_peers + write_nodes_entries: the values list holds one compact endpoint string per peer.
Build a ping query: {t, y:"q", q:"ping", a:{id}}. Mirrors the e["q"]="ping" branch of node::send_single_refresh.
Build a bare response carrying only id: {t, y:"r", r:{id}}. This is what ping/announce_peer reply with (incoming_request adds nothing beyond t and id).
Build a put query: a{id, token, v, [k, seq, sig, salt, cas]}. Faithful to put_data::invoke: it splices the value in as its exact bencoding, so the signature still verifies, and it adds the mutable extras only for a MutableItem.
Parse a decoded KRPC envelope node into a typed DhtMessage, or null if the message is malformed (not a dict, missing/!string t or y, unknown y, missing payload, or a 20-byte-id violation).