summaryrefslogtreecommitdiff
path: root/src/Network/Tox/Crypto/Handlers.hs
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2018-05-30 02:31:45 +0000
committerJames Crayne <jim.crayne@gmail.com>2018-05-30 02:31:45 +0000
commite82c3f9982ffd1cf7d7dd522da249f1020be5aa1 (patch)
treed4fad6eee7351958e296e383d3448946bd9e6f20 /src/Network/Tox/Crypto/Handlers.hs
parent28eae4262ae7c31d77f09a10020ec6a0005a207d (diff)
more debug messages in cryptoNetHandler
Diffstat (limited to 'src/Network/Tox/Crypto/Handlers.hs')
-rw-r--r--src/Network/Tox/Crypto/Handlers.hs25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs
index f4199374..268928ee 100644
--- a/src/Network/Tox/Crypto/Handlers.hs
+++ b/src/Network/Tox/Crypto/Handlers.hs
@@ -545,10 +545,23 @@ updateCryptoSession sessions addr hp session = do
545 -- duplicate handshake packet, otherwise disregard everything, and 545 -- duplicate handshake packet, otherwise disregard everything, and
546 -- refresh all state. 546 -- refresh all state.
547 -- 547 --
548 then when ( Just ncTheirBaseNonce0 /= hpTheirBaseNonce hp -- XXX: Do we really want to compare base nonce here? 548 then do
549 dput XNetCrypto "updateCryptoSession already accepted.."
550 dput XNetCrypto (" ncTheirBaseNonce0=" ++ show ncTheirBaseNonce0
551 ++ bool "(/=)" "(==)" (Just ncTheirBaseNonce0 == hpTheirBaseNonce hp)
552 ++ "hpTheirBaseNonce=" ++ show (hpTheirBaseNonce hp))
553 dput XNetCrypto (" ncTheirDHTKey=" ++ show (ncTheirDHTKey session)
554 ++ bool "{/=}" "{==}" (ncTheirDHTKey session == hpCookieRemoteDhtkey hp)
555 ++ "hpCookieRemoteDhtkey=" ++ show (hpCookieRemoteDhtkey hp))
556 when ( Just ncTheirBaseNonce0 /= hpTheirBaseNonce hp -- XXX: Do we really want to compare base nonce here?
549 || ncTheirDHTKey session /= hpCookieRemoteDhtkey hp 557 || ncTheirDHTKey session /= hpCookieRemoteDhtkey hp
550 ) $ freshCryptoSession sessions addr hp 558 ) $ freshCryptoSession sessions addr hp
551 else if ( Just ncTheirBaseNonce0 /= hpTheirBaseNonce hp) 559 else do
560 dput XNetCrypto "updateCryptoSession else clause"
561 dput XNetCrypto (" ncTheirBaseNonce0=" ++ show ncTheirBaseNonce0
562 ++ bool "(/=)" "(==)" (Just ncTheirBaseNonce0 == hpTheirBaseNonce hp)
563 ++ "hpTheirBaseNonce=" ++ show (hpTheirBaseNonce hp))
564 if ( Just ncTheirBaseNonce0 /= hpTheirBaseNonce hp)
552 then freshCryptoSession sessions addr hp -- basenonce mismatch, trigger refresh 565 then freshCryptoSession sessions addr hp -- basenonce mismatch, trigger refresh
553 else atomically $ writeTVar (ncState session) Accepted 566 else atomically $ writeTVar (ncState session) Accepted
554 567
@@ -620,8 +633,12 @@ cryptoNetHandler sessions addr (NetHandshake (Handshake (Cookie n24 ecookie) non
620 sessionsmap <- atomically $ readTVar allsessions 633 sessionsmap <- atomically $ readTVar allsessions
621 -- Do a lookup, so we can handle the update case differently 634 -- Do a lookup, so we can handle the update case differently
622 case Map.lookup addr sessionsmap of 635 case Map.lookup addr sessionsmap of
623 Nothing -> freshCryptoSession sessions addr hp -- create new session 636 Nothing -> do
624 Just session -> updateCryptoSession sessions addr hp session -- update existing session 637 dput XNetCrypto "sockaddr not in session map, so freshCryptoSession"
638 freshCryptoSession sessions addr hp -- create new session
639 Just session -> do
640 dput XNetCrypto "sockaddr ALREADY in session map, so updateCryptoSession"
641 updateCryptoSession sessions addr hp session -- update existing session
625 return Nothing 642 return Nothing
626 643
627cryptoNetHandler sessions addr (NetCrypto (CryptoPacket nonce16 encrypted)) = do 644cryptoNetHandler sessions addr (NetCrypto (CryptoPacket nonce16 encrypted)) = do