Status of a tox friend netcrypto session. ----------------------------------------- data ToxProgress = AwaitingDHTKey -- ^ Waiting to receive their DHT key. | AcquiringIPAddress -- ^ Searching DHT to obtain their node's IP & port. | AcquiringCookie -- ^ Attempting to obtain a cookie. | AwaitingHandshake -- ^ Waiting to receive a handshake. | AwaitingSessionPacket -- ^ Connection is "accepted" but not yet "confirmed". deriving (Eq,Ord,Enum,Show) Information about contact toxid and events that provide it. ---------------------------------------------------------- SockAddr receive packet with dhtkey associated with toxid receive query result with dhtkey associated with toxid receive netcrypto session packet from toxid DHTKey receive dhtpk over DataToRoute transport. receive dht message from SockAddr receive dhtpk via dht-request Recurring tasks associated with obtaining a connection. ------------------------------------------------------- while (account is active): tox4id:announce{toxid} tox6id: while (policy=TryingToConnect and friend session is not established) search{toxid} contact, send my dhtkey to results (AwaitingDHTKey .. AwaitingSessionPacket) while (dhtkey is fresh but sockaddr is stale) search{node} dhtkey (AcquiringIPAddress..) while (dhtkey and sockaddr are fresh) (AcquiringCookie) getCookie { on timeout, consider sockaddr stale, set sockaddr to Nothing) (AwaitingHandshake) send handshake Plan: Suppose our user key is OrjBG.GyWuQhGc1pb0KssgmYAocohFh35Vx8mREC9Nu and we have a contact with user key DdhbLjiwaV0GAiGKgesNPbvj2TbhrBHEWEEc5icfvQN. The following AnnounceKeys will be scheduled: toxid:OrjBG.GyWuQhGc1pb0KssgmYAocohFh35Vx8mREC9Nu This task searches for our own user key, and publishes itself at rendezvous nodes. dhtkey:OrjBG.Gy:DdhbLjiwaV0GAiGKgesNPbvj2TbhrBHEWEEc5icfvQN This task searches for our contact's user key and uses the rendezvous nodes that it finds in order to share our dhtkey with our contact. connect:OrjBG.Gy:DdhbLjiwaV0GAiGKgesNPbvj2TbhrBHEWEEc5icfvQN Depending on whether or not the ip/port is "fresh", this task has two modes only one of which is active at a time: (1) (stale) Search for our contact's dhtkey (nodeid) in order to discover his ip address and port. (2) (fresh) Send handshakes to our friend every 5 seconds. The toxid:* task will be scheduled as long as you are online. The dhtkey:* and connect:* will only be scheduled when there is no active "netcrypto" session link with your contact. On inbound ---------- Handshake recieved! (AwaitingSessionPacket) Interesting tox repositories -------------------------------------------- https://github.com/TokTok/spec https://github.com/TokTok/hs-toxcore https://github.com/iphydf/hstox https://github.com/TokTok/c-toxcore