summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2020-01-15 20:12:26 -0500
committerJoe Crayne <joe@jerkface.net>2020-01-16 00:15:27 -0500
commit32a9be9211583f8405e92ecc1158f035141820be (patch)
treedf319f99b0a64048588fba7d93298a8b58d37094
parentf00396cf25cf3aaf3f1e4209804bede37d79605f (diff)
Rewrite ConnectNotification to RoutingResponse.
-rw-r--r--dht/src/Network/Tox/TCP.hs16
1 files changed, 14 insertions, 2 deletions
diff --git a/dht/src/Network/Tox/TCP.hs b/dht/src/Network/Tox/TCP.hs
index cb0f0a1b..f8ec430b 100644
--- a/dht/src/Network/Tox/TCP.hs
+++ b/dht/src/Network/Tox/TCP.hs
@@ -429,9 +429,21 @@ partitionRelay tr = partitionTransportM parse encode tr
429 return $ Left (bs, ViaRelay (Just conid) nid ni) 429 return $ Left (bs, ViaRelay (Just conid) nid ni)
430 parse ((_,OOBRecv key bs), ni) = 430 parse ((_,OOBRecv key bs), ni) =
431 return $ Left (bs, ViaRelay Nothing (UDP.key2id key) ni) 431 return $ Left (bs, ViaRelay Nothing (UDP.key2id key) ni)
432 parse passthrough@((st,RoutingResponse conid k),ni) = do 432 parse ((st,RoutingResponse conid k),ni) = do
433 setRelayedRemote st conid (UDP.key2id k) 433 setRelayedRemote st conid (UDP.key2id k)
434 return $ Right passthrough 434 -- Note: Rewriting inbound RoutingResponse to be a RoutingRequest
435 -- instead. This is because the routing reqest is not yet fullfilled
436 -- until a ConnectNotification is received.
437 --
438 -- We could use Left here instead as inbound RoutingRequest packets are
439 -- not normally responded to by a client.
440 return $ Right ((st,RoutingRequest k),ni)
441 parse ((st,ConnectNotification conid),ni) = do
442 nid <- getRelayedRemote st conid
443 -- Note: Rewriting inbound ConnectNotification to a RoutingResponse
444 -- because we want to include the public key and connection id in a
445 -- single message.
446 return $ Right ((st,RoutingResponse conid (UDP.id2key nid)),ni)
435 parse passthrough = 447 parse passthrough =
436 return $ Right passthrough 448 return $ Right passthrough
437 449