From 3594f51aa4834b546440228d863c2a8d9ec884d6 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Sat, 23 Jun 2018 19:44:47 -0400 Subject: sketch data representation of the netcrypto negotiation state --- ToxToXMPP.hs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'ToxToXMPP.hs') diff --git a/ToxToXMPP.hs b/ToxToXMPP.hs index 8c57da5a..56cc297f 100644 --- a/ToxToXMPP.hs +++ b/ToxToXMPP.hs @@ -152,6 +152,25 @@ nodeinfoStaleTime = 600 nodeinfoSearchInterval :: POSIXTime nodeinfoSearchInterval = 15 +data Awaiting v = Since POSIXTime +data Acquired v = At POSIXTime v +data Moot v = Moot + +data NNS a b c = NNS { -- NetcryptoNegotiationState + sessionDesired :: Bool, + theirPublicKey :: a Tox.DHTPublicKey, + theirAddress :: b SockAddr, + theirCookie :: c (Tox.Cookie Encrypted), + sessionIsActive :: Bool +} + +data NS + = Stage1 (NNS Moot Moot Moot) + | Stage2 (NNS Awaiting Moot Moot) + | Stage3 (NNS Acquired Awaiting Moot) + | Stage4 (NNS Acquired Acquired Awaiting) + | Stage5 (NNS Acquired Acquired Acquired) + gotDhtPubkey :: Tox.DHTPublicKey -> ToxToXMPP -> PublicKey -> IO () gotDhtPubkey pubkey tx theirKey = do contact <- atomically $ getContact theirKey (txAccount tx) >>= mapM (readTVar . contactLastSeenAddr) -- cgit v1.2.3