summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2020-01-09 12:11:09 -0500
committerJoe Crayne <joe@jerkface.net>2020-01-09 12:11:09 -0500
commitfb8196cde5a56337a0e028f837a34ef1bdbcc94f (patch)
treec2766ccd83bab8140978a8fc6e4cc73a60f6b736
parent5e2f6f9f8b78b90f0becb60e735abbd62bac6ca6 (diff)
Debug prints when packets when packets are relayed between peers.
-rw-r--r--dht/src/Network/Tox/Relay.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/dht/src/Network/Tox/Relay.hs b/dht/src/Network/Tox/Relay.hs
index 3aa596ab..22a692a9 100644
--- a/dht/src/Network/Tox/Relay.hs
+++ b/dht/src/Network/Tox/Relay.hs
@@ -206,19 +206,22 @@ handlePacket cons thistcp me crypto sendOnion sendToMe session = \case
206 RelayPing x -> sendToMe $ RelayPong x -- TODO x==0 is invalid. Do we care? 206 RelayPing x -> sendToMe $ RelayPong x -- TODO x==0 is invalid. Do we care?
207 207
208 OOBSend them bs -> do 208 OOBSend them bs -> do
209 dput XRelay $ "OOB send to " ++ showKey256 them
209 m <- atomically $ Map.lookup them <$> readTVar cons 210 m <- atomically $ Map.lookup them <$> readTVar cons
210 forM_ m $ \(sendToThem,_) -> sendToThem $ OOBRecv me bs 211 forM_ m $ \(sendToThem,_) -> sendToThem $ OOBRecv me bs
211 212
212 RelayData bs con -> join $ atomically $ do 213 RelayData bs con -> do
214 mySession <- atomically $ readTVar session
213 -- Data: Data packets can only be sent and received if the 215 -- Data: Data packets can only be sent and received if the
214 -- corresponding connection_id is connection (a Connect notification 216 -- corresponding connection_id is connection (a Connect notification
215 -- has been received from it) if the server receives a Data packet for 217 -- has been received from it) if the server receives a Data packet for
216 -- a non connected or existent connection it will discard it. 218 -- a non connected or existent connection it will discard it.
217 mySession <- readTVar session 219 let mbSendIt = do
218 return $ sequence_ $ do 220 i <- c2key con
219 i <- c2key con 221 sendToThem' <- IntMap.lookup i $ associated mySession
220 sendToThem' <- IntMap.lookup i $ associated mySession 222 return $ sendToThem' $ RelayData bs
221 return $ sendToThem' $ RelayData bs 223 dput XRelay $ "RelayData to con " ++ show con ++ maybe "to no key" (\io -> "to an associatied key") mbSendIt
224 sequence_ mbSendIt
222 225
223 OnionPacket n24 (Addressed addr req) -> do 226 OnionPacket n24 (Addressed addr req) -> do
224 dput XOnion $ "Received onion request via TCP client conid="++show thistcp 227 dput XOnion $ "Received onion request via TCP client conid="++show thistcp