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 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