summaryrefslogtreecommitdiff
path: root/src/Network/Tox
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/Tox')
-rw-r--r--src/Network/Tox/Onion/Transport.hs19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/Network/Tox/Onion/Transport.hs b/src/Network/Tox/Onion/Transport.hs
index eabd9473..989b06fd 100644
--- a/src/Network/Tox/Onion/Transport.hs
+++ b/src/Network/Tox/Onion/Transport.hs
@@ -192,8 +192,7 @@ encodeOnionAddr _ (msg,OnionDestination _ Nothing ) = do
192 hPutStrLn stderr $ "ONION encode missing routeid" 192 hPutStrLn stderr $ "ONION encode missing routeid"
193 return Nothing 193 return Nothing
194encodeOnionAddr getRoute (msg,OnionDestination ni (Just rid)) = do 194encodeOnionAddr getRoute (msg,OnionDestination ni (Just rid)) = do
195 let go route0 = do 195 let go route = do
196 let route = route0 { routeNonce = msgNonce msg } -- TODO: This necessary?
197 return ( runPut $ putRequest $ wrapForRoute msg ni route 196 return ( runPut $ putRequest $ wrapForRoute msg ni route
198 , nodeAddr $ routeNodeA route) 197 , nodeAddr $ routeNodeA route)
199 mapM' f x = do 198 mapM' f x = do
@@ -635,8 +634,7 @@ transcode f (OnionToRouteResponse a) = OnionToRouteResponse a
635 634
636 635
637data OnionRoute = OnionRoute 636data OnionRoute = OnionRoute
638 { routeNonce :: Nonce24 637 { routeAliasA :: SecretKey
639 , routeAliasA :: SecretKey
640 , routeAliasB :: SecretKey 638 , routeAliasB :: SecretKey
641 , routeAliasC :: SecretKey 639 , routeAliasC :: SecretKey
642 , routeNodeA :: NodeInfo 640 , routeNodeA :: NodeInfo
@@ -645,18 +643,21 @@ data OnionRoute = OnionRoute
645 } 643 }
646 644
647wrapForRoute :: OnionMessage Encrypted -> NodeInfo -> OnionRoute -> OnionRequest N0 645wrapForRoute :: OnionMessage Encrypted -> NodeInfo -> OnionRoute -> OnionRequest N0
648wrapForRoute msg ni r = OnionRequest 646wrapForRoute msg ni r =
649 { onionNonce = routeNonce r 647 -- We needn't use the same nonce value here, but I think it is safe to do so.
648 let nonce = msgNonce msg
649 in OnionRequest
650 { onionNonce = nonce
650 , onionForward = wrapOnion (routeAliasA r) 651 , onionForward = wrapOnion (routeAliasA r)
651 (routeNonce r) 652 nonce
652 (id2key . nodeId $ routeNodeA r) 653 (id2key . nodeId $ routeNodeA r)
653 (nodeAddr $ routeNodeB r) 654 (nodeAddr $ routeNodeB r)
654 $ wrapOnion (routeAliasB r) 655 $ wrapOnion (routeAliasB r)
655 (routeNonce r) 656 nonce
656 (id2key . nodeId $ routeNodeB r) 657 (id2key . nodeId $ routeNodeB r)
657 (nodeAddr $ routeNodeC r) 658 (nodeAddr $ routeNodeC r)
658 $ wrapOnion (routeAliasC r) 659 $ wrapOnion (routeAliasC r)
659 (routeNonce r) 660 nonce
660 (id2key . nodeId $ routeNodeC r) 661 (id2key . nodeId $ routeNodeC r)
661 (nodeAddr ni) 662 (nodeAddr ni)
662 $ NotForwarded msg 663 $ NotForwarded msg