Open
Description
Description of DHT PK packets
Onion client works using onion, tcp_relay and dht to manage exchanging node's PK and connections to friends.
Tox client calls onion client's main loop, this loop do
- check if onion is connected to tox networks
- last time of received packet is past 75 seconds => onion is not connected.
- there is no path entry in path list => onion is not connected.
- if onion is not connected to Tox networks then
- populate path list from tcp_relay module
- if onion is connected to tox networks then
- do things below for every friend
- check if friend is online
- if friend is online then
- skip this friend
- if friend is not online then
- send AnnounceRequest to all of friend's client list
- if some node of friend's client list is timed out then
- send AnnounceRequest to random node of path list
- if some node of friend's client list is timed out then
- send AnnounceRequest to all of friend's client list
- there are two timer interval, dhtpk for dht and dhtpk for onion
- if dhtpk interval timer for dht expires then
- create ONION_DATA_DHTPK payload
- get node list from close list of freind which is in dht
- create CRYPTO_PACKET_DHTPK packet
- send packet to all node
- if dhtpk interval timer for onion expires then
- create ONION_DATA_DHTPK payload
- get destination nodes from friend's client list
- for each destination node do
- create OnionDataRequest packet
- if destination address is UDP then
- send packet using UDP
- if destination address is TCP then
- send packet using TCP client's secure connection
- do things below for every friend
- if 3 seconds have passed since booting of onion then
- get random path from onion's path list
- create OnionAnnounce packet using onion's PK
- send packet using TCP or UDP
- get random path from onion friend's path list
- create OnionAnnounce packet using friend's PK
- send packet using TCP or UDP
- get random path from onion's path list
When dhtpk packet is received then
- decrypt
- if PK differs from current PK then
- delete DHT friend
- create DHT friend with new PK
- make a new friend connection
- set onion friend's dht PK
- unpack received packet then for each nodes
- if node is UDP then
- send NodesRequest
- if node is TCP then
- add node to tcp relay list and friend's tcp relay list
- if node is UDP then
When AnnounceResponse packet is received then
- decrypt packet
- init path's timeout variables
- copy nodes to path_nodes list
- add nodes to list to be announced or friend's client list
- init nodes added
- for each node of payload do
- if node's IP is within LAN then skip
- if destinaiton node is timed out then skip
- if node is already in list to be announced or friend's client list then skip
- send AnnounceRequest to node
When OnionDataResponse packet is received from onion then
- decrypt packet
- process packet using handler for dhtpk announce
When packet is received from TCP client then
- if packet is AnnounceResponse then
- process packet using handler for AnnounceResponse
- if packet is OnionDataResponse then
- process packet using handler for OnionDataResponse
Metadata
Metadata
Assignees
Labels
No labels