summaryrefslogtreecommitdiff
path: root/dht/src/Network/Tox/Onion/Handlers.hs
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-12-14 16:11:03 -0500
committerJoe Crayne <joe@jerkface.net>2020-01-01 23:26:49 -0500
commitd5efdc327bbb69a905043df45415817e318e38ee (patch)
tree7be975048f3e40c27811bdb39ba92d871a42588c /dht/src/Network/Tox/Onion/Handlers.hs
parent8c04d9cca70241bebe4b94b779fe7bbfe6140f51 (diff)
Multi Transports: TCP for DHT/Cookies/Handshakes.
Diffstat (limited to 'dht/src/Network/Tox/Onion/Handlers.hs')
-rw-r--r--dht/src/Network/Tox/Onion/Handlers.hs11
1 files changed, 3 insertions, 8 deletions
diff --git a/dht/src/Network/Tox/Onion/Handlers.hs b/dht/src/Network/Tox/Onion/Handlers.hs
index 52dcf536..7951e707 100644
--- a/dht/src/Network/Tox/Onion/Handlers.hs
+++ b/dht/src/Network/Tox/Onion/Handlers.hs
@@ -3,6 +3,7 @@
3{-# LANGUAGE PatternSynonyms #-} 3{-# LANGUAGE PatternSynonyms #-}
4module Network.Tox.Onion.Handlers where 4module Network.Tox.Onion.Handlers where
5 5
6import qualified Data.Tox.DHT.Multi as Multi
6import Network.Kademlia.Search 7import Network.Kademlia.Search
7import Network.Tox.TCP.NodeId (udpNodeInfo) 8import Network.Tox.TCP.NodeId (udpNodeInfo)
8import Network.Tox.DHT.Transport 9import Network.Tox.DHT.Transport
@@ -29,6 +30,7 @@ import Control.Concurrent
29import GHC.Conc (labelThread) 30import GHC.Conc (labelThread)
30#endif 31#endif
31import Control.Concurrent.STM 32import Control.Concurrent.STM
33import Data.Dependent.Sum ( (==>) )
32import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime) 34import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime)
33import Network.Socket 35import Network.Socket
34#if MIN_VERSION_iproute(1,7,4) 36#if MIN_VERSION_iproute(1,7,4)
@@ -78,7 +80,7 @@ announceH routing toks keydb oaddr req = do
78 where 80 where
79 go withTok = do 81 go withTok = do
80 let naddr = onionNodeInfo oaddr 82 let naddr = onionNodeInfo oaddr
81 ns <- getNodesH routing naddr (GetNodes (announceSeeking req)) 83 ns <- getNodesH routing (Multi.UDP ==> naddr) (GetNodes (announceSeeking req))
82 tm <- getPOSIXTime 84 tm <- getPOSIXTime
83 85
84 let storing = case oaddr of 86 let storing = case oaddr of
@@ -251,13 +253,6 @@ announceSerializer getTimeout = MethodSerializer
251 _ -> Nothing 253 _ -> Nothing
252 } 254 }
253 255
254unwrapAnnounceResponse :: Maybe NodeId -> NodeInfo -> AnnounceResponse -> ([NodeInfo], [Rendezvous], Maybe Nonce32)
255unwrapAnnounceResponse alias ni (AnnounceResponse is_stored (SendNodes ns0)) | let ns = map udpNodeInfo ns0
256 = case is_stored of
257 NotStored n32 -> ( ns , [] , Just n32)
258 SendBackKey k -> ( ns , [Rendezvous k ni] , Nothing )
259 Acknowledged n32 -> ( ns , maybeToList $ fmap (\k -> Rendezvous (id2key k) ni) alias , Just n32)
260
261-- TODO Announce key to announce peers. 256-- TODO Announce key to announce peers.
262-- 257--
263-- Announce Peers are only put in the 8 closest peers array if they respond 258-- Announce Peers are only put in the 8 closest peers array if they respond