diff options
Diffstat (limited to 'dht/src/Network/Tox')
-rw-r--r-- | dht/src/Network/Tox/TCP.hs | 16 |
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 | ||