summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Network/Tox/Crypto/Handlers.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs
index 8975e4dc..fd04e1c5 100644
--- a/src/Network/Tox/Crypto/Handlers.hs
+++ b/src/Network/Tox/Crypto/Handlers.hs
@@ -467,6 +467,7 @@ ncToWire :: STM (State,Nonce24,U.RangeMap TArray Word8 TVar)
467 -> XMessage 467 -> XMessage
468 -> STM (Maybe (CryptoPacket Encrypted,Word32{-next packet no-})) 468 -> STM (Maybe (CryptoPacket Encrypted,Word32{-next packet no-}))
469ncToWire getState seqno bufend pktno msg = do 469ncToWire getState seqno bufend pktno msg = do
470 dtrace XNetCrypto ("ncToWire TOP OF FUNCTION " ++ show msg) (return ())
470 let typ = getMessageType msg 471 let typ = getMessageType msg
471 typ64 = toWord64 typ 472 typ64 = toWord64 typ
472 let lsness msg = 473 let lsness msg =
@@ -681,6 +682,7 @@ createNetCryptoOutQueue :: NetCryptoSessions -> SecretKey -> PublicKey -> Packet
681createNetCryptoOutQueue sessions newsession theirSessionKey pktq ncMyPacketNonce0 ncOutgoingIdMap0 = do 682createNetCryptoOutQueue sessions newsession theirSessionKey pktq ncMyPacketNonce0 ncOutgoingIdMap0 = do
682 let crypto = transportCrypto sessions 683 let crypto = transportCrypto sessions
683 let toWireIO = do 684 let toWireIO = do
685 dput XNetCrypto "=========== toWireIO TOP ==================="
684 f <- lookupNonceFunction crypto newsession theirSessionKey 686 f <- lookupNonceFunction crypto newsession theirSessionKey
685 atomically $ do 687 atomically $ do
686 n24 <- readTVar ncMyPacketNonce0 688 n24 <- readTVar ncMyPacketNonce0
@@ -761,6 +763,7 @@ tryAppendQueueOutgoing :: STM (State, Nonce24, U.RangeMap TArray Word8 TVar)
761 -> CryptoMessage 763 -> CryptoMessage
762 -> STM (OutGoingResult (CryptoPacket Encrypted)) 764 -> STM (OutGoingResult (CryptoPacket Encrypted))
763tryAppendQueueOutgoing getExtra outq msg = do 765tryAppendQueueOutgoing getExtra outq msg = do
766 dtrace XNetCrypto ("tryAppendQueueOutgoing=========>DEBUG====?> " ++ show msg) (return ())
764 pktno <- readTVar (nqPacketNo outq) 767 pktno <- readTVar (nqPacketNo outq)
765 nextno <- PB.expectingSequenceNumber (nqPacketBuffer outq) 768 nextno <- PB.expectingSequenceNumber (nqPacketBuffer outq)
766 be <- PB.nextToSendSequenceNumber (nqPacketBuffer outq) 769 be <- PB.nextToSendSequenceNumber (nqPacketBuffer outq)
@@ -1252,7 +1255,7 @@ sendCrypto :: TransportCrypto -> NetCryptoSession -> (STM ()) -> CryptoMessage -
1252sendCrypto crypto session updateLocal cm = do 1255sendCrypto crypto session updateLocal cm = do
1253 HaveHandshake outq <- atomically $ readTVar (ncOutgoingQueue session) 1256 HaveHandshake outq <- atomically $ readTVar (ncOutgoingQueue session)
1254 -- XXX: potential race? if shared secret comes out of sync with cache? 1257 -- XXX: potential race? if shared secret comes out of sync with cache?
1255 dput XNetCrypto "sendCrypto: enter " 1258 dput XNetCrypto ("sendCrypto: ENTER MESSAGE: " ++ show cm)
1256 getOutGoingParam <- nqToWireIO outq 1259 getOutGoingParam <- nqToWireIO outq
1257 dput XNetCrypto "sendCrypto: got the io extra stuff" 1260 dput XNetCrypto "sendCrypto: got the io extra stuff"
1258 ncTime <- atomically $ readTVar (ncTimeOut session) 1261 ncTime <- atomically $ readTVar (ncTimeOut session)
@@ -1299,12 +1302,13 @@ sendOnlineHook crypto session cm = do
1299sendOffline :: TransportCrypto -> NetCryptoSession -> IO (Either String (CryptoPacket Encrypted)) 1302sendOffline :: TransportCrypto -> NetCryptoSession -> IO (Either String (CryptoPacket Encrypted))
1300sendOffline crypto session = do 1303sendOffline crypto session = do
1301 let cm=OneByte OFFLINE 1304 let cm=OneByte OFFLINE
1302 sendLossless crypto session cm 1305 sendLossless crypto session (OneByte OFFLINE)
1306
1303 1307
1304sendLossless :: TransportCrypto -> NetCryptoSession -> CryptoMessage -> IO (Either String (CryptoPacket Encrypted)) 1308sendLossless :: TransportCrypto -> NetCryptoSession -> CryptoMessage -> IO (Either String (CryptoPacket Encrypted))
1305sendLossless crypto session cm = do 1309sendLossless crypto session cm = do
1306 addMsgToLastN False (cm ^. messageType) session (Out cm) 1310 addMsgToLastN False (cm ^. messageType) session (Out cm)
1307 sendCrypto crypto session (return ()) (OneByte OFFLINE) 1311 sendCrypto crypto session (return ()) cm
1308 1312
1309sendLossy :: TransportCrypto -> NetCryptoSession -> CryptoMessage -> IO (Either String (CryptoPacket Encrypted)) 1313sendLossy :: TransportCrypto -> NetCryptoSession -> CryptoMessage -> IO (Either String (CryptoPacket Encrypted))
1310sendLossy crypto session cm = sendCryptoLossy crypto session (return ()) cm 1314sendLossy crypto session cm = sendCryptoLossy crypto session (return ()) cm