[][src]Module tox_packet::dht

Top-level DHT udp packets according to Tox spec

Modules

packed_node

A pair of SocketAddr & PublicKey.

Structs

BootstrapInfo

Sent by both client and server, only server will respond. When server receives this packet it may respond with the version of the library plus MoTD (message of the day). The max length of MoTD is 256 bytes so the max packet lenght of server BootstrapInfo is 261=(1+4+256) bytes.

Cookie

Cookie is a struct that holds two public keys of a node: long term key and short term DHT key.

CookieRequest

CookieRequest packet struct. According to https://zetok.github.io/tox-spec/#net-crypto

CookieRequestPayload

CookieRequestPayload packet struct.

CookieResponse

Response to a CookieRequest packet.

CookieResponsePayload

Unencrypted payload of CookieResponse packet.

CryptoData

Packet used to send data over net_crypto connection.

CryptoDataPayload

Unencrypted payload of CryptoData packet.

CryptoHandshake

Packet used to establish net_crypto connection between two peers.

CryptoHandshakePayload

Unencrypted payload of CryptoHandshake packet.

DhtPkAnnounce

Packet to announce self short term DHT PublicKey to a friend.

DhtPkAnnouncePayload

Packet used to announce our DHT PublicKey to a friend. Can be sent as inner packet of OnionDataResponse and DhtRequest packets.

DhtRequest

DHT Request packet struct. DHT Request packet consists of NatPingRequest and NatPingResponse. When my known friend is not connected directly, send NatPingRequest to peers which are in Ktree. When NatPingResponse arrives to me, it means that my known friend is also searching me, and running behind NAT, so start hole-punching.

EncryptedCookie

Encrypted with symmetric key Cookie.

GetPayloadError

Error that can happen when calling get_payload of packet.

HardeningRequest

Hardening nodes request of DHT Request packet.

HardeningResponse

Hardening nodes response of DHT Request packet.

LanDiscovery

LanDiscovery packet struct. LanDiscovery packets contain the DHT public key of the sender. When a LanDiscovery packet is received, a NodesRequest packet will be sent to the sender of the packet. This means that the DHT instance will bootstrap itself to every peer from which it receives one of these packet. Through this mechanism, Tox clients will bootstrap themselve automatically from other Tox clients running on the local network.

NatPingRequest

NatPing request of DHT Request packet.

NatPingResponse

NatPing response of DHT Request packet.

NodesRequest

Nodes request packet struct. It's used to get up to 4 closest nodes to requested public key. Every 20 seconds DHT node sends NodesRequest packet to a random node in ktree and its known friends list.

NodesRequestPayload

Request to get address of given DHT PK, or nodes that are closest in DHT to the given PK. Request id is used for resistance against replay attacks.

NodesResponse

Nodes response packet struct. When DHT node receives NodesRequest it should respond with NodesResponse that contains up to to 4 closest nodes to requested public key. Ping id should be the same as it was in NodesRequest.

NodesResponsePayload

Response to NodesRequest request, containing up to 4 nodes closest to the requested node. Request id is used for resistance against replay attacks.

PingRequest

Ping request packet struct. Every 60 seconds DHT node sends PingRequest packet to peers to check whether it is alive. When PingRequest is received DHT node should respond with PingResponse that contains the same ping id inside it's encrypted payload as it got from PingRequest. If PingResponse doesn't arrive for 122 seconds the DHT node removes peer from ktree and marks it as offline if the peer is known friend.

PingRequestPayload

Used to request/respond to ping. Used in an encrypted form. Request id is used for resistance against replay attacks.

PingResponse

Ping response packet struct. When PingRequest is received DHT node should respond with PingResponse that contains the same ping id inside it's encrypted payload as it got from PingRequest.

PingResponsePayload

Used to request/respond to ping. Used in an encrypted form. Request id is used for resistance against replay attacks.

Enums

DhtRequestPayload

Standart DHT Request packet that embedded in the payload of DhtRequest.

GetPayloadErrorKind

The specific kind of error that can occur.

Packet

DHT packet enum that encapsulates all types of DHT packets.

Constants

BOOSTRAP_CLIENT_MAX_MOTD_LENGTH

Length of in bytes of MoTD field of BootstrapInfo when client requests info. 73 = 78 (max client request len) - 1 (type) - 4 (version)

BOOSTRAP_SERVER_MAX_MOTD_LENGTH

Length of in bytes of MoTD field of BootstrapInfo when server responds with info.

COOKIE_TIMEOUT

Number of seconds that generated cookie is valid

MAX_CRYPTO_DATA_SIZE

The maximum size of data in packets.

MAX_DHT_PACKET_SIZE

A serialized Packet should be not longer than 2048 bytes.

Functions

unix_time