diff options
Diffstat (limited to 'dht/src/Network/Tox/Onion/Transport.hs')
-rw-r--r-- | dht/src/Network/Tox/Onion/Transport.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/dht/src/Network/Tox/Onion/Transport.hs b/dht/src/Network/Tox/Onion/Transport.hs index e746c414..407cd387 100644 --- a/dht/src/Network/Tox/Onion/Transport.hs +++ b/dht/src/Network/Tox/Onion/Transport.hs | |||
@@ -38,15 +38,19 @@ module Network.Tox.Onion.Transport | |||
38 | , wrapSymmetric | 38 | , wrapSymmetric |
39 | , wrapOnion | 39 | , wrapOnion |
40 | , wrapOnionPure | 40 | , wrapOnionPure |
41 | , unwrapAnnounceResponse | ||
41 | ) where | 42 | ) where |
42 | 43 | ||
43 | import Data.ByteString (ByteString) | 44 | import Data.ByteString (ByteString) |
45 | import Data.Maybe | ||
44 | import Data.Serialize | 46 | import Data.Serialize |
45 | import Network.Socket | 47 | import Network.Socket |
46 | 48 | ||
47 | import Crypto.Tox hiding (encrypt,decrypt) | 49 | import Crypto.Tox hiding (encrypt,decrypt) |
50 | import Network.Tox.TCP.NodeId (udpNodeInfo) | ||
48 | import qualified Data.Tox.Relay as TCP | 51 | import qualified Data.Tox.Relay as TCP |
49 | import Data.Tox.Onion | 52 | import Data.Tox.Onion |
53 | import Network.Tox.DHT.Transport (SendNodes(..)) | ||
50 | import Network.Tox.NodeId | 54 | import Network.Tox.NodeId |
51 | 55 | ||
52 | {- | 56 | {- |
@@ -117,3 +121,10 @@ wrapForRoute crypto msg ni r@OnionRoute{routeRelayPort = Just tcpport} = do | |||
117 | (nodeAddr ni) | 121 | (nodeAddr ni) |
118 | (NotForwarded msg) | 122 | (NotForwarded msg) |
119 | return $ Left $ TCP.OnionPacket nonce $ Addressed (nodeAddr $ routeNodeB r) fwd | 123 | return $ Left $ TCP.OnionPacket nonce $ Addressed (nodeAddr $ routeNodeB r) fwd |
124 | |||
125 | unwrapAnnounceResponse :: Maybe NodeId -> NodeInfo -> AnnounceResponse -> ([NodeInfo], [Rendezvous], Maybe Nonce32) | ||
126 | unwrapAnnounceResponse alias ni (AnnounceResponse is_stored (SendNodes ns0)) | let ns = map udpNodeInfo ns0 | ||
127 | = case is_stored of | ||
128 | NotStored n32 -> ( ns , [] , Just n32) | ||
129 | SendBackKey k -> ( ns , [Rendezvous k ni] , Nothing ) | ||
130 | Acknowledged n32 -> ( ns , maybeToList $ fmap (\k -> Rendezvous (id2key k) ni) alias , Just n32) | ||