From d5efdc327bbb69a905043df45415817e318e38ee Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Sat, 14 Dec 2019 16:11:03 -0500 Subject: Multi Transports: TCP for DHT/Cookies/Handshakes. --- dht/src/Network/Tox/Onion/Handlers.hs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'dht/src/Network/Tox/Onion/Handlers.hs') 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 @@ {-# LANGUAGE PatternSynonyms #-} module Network.Tox.Onion.Handlers where +import qualified Data.Tox.DHT.Multi as Multi import Network.Kademlia.Search import Network.Tox.TCP.NodeId (udpNodeInfo) import Network.Tox.DHT.Transport @@ -29,6 +30,7 @@ import Control.Concurrent import GHC.Conc (labelThread) #endif import Control.Concurrent.STM +import Data.Dependent.Sum ( (==>) ) import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime) import Network.Socket #if MIN_VERSION_iproute(1,7,4) @@ -78,7 +80,7 @@ announceH routing toks keydb oaddr req = do where go withTok = do let naddr = onionNodeInfo oaddr - ns <- getNodesH routing naddr (GetNodes (announceSeeking req)) + ns <- getNodesH routing (Multi.UDP ==> naddr) (GetNodes (announceSeeking req)) tm <- getPOSIXTime let storing = case oaddr of @@ -251,13 +253,6 @@ announceSerializer getTimeout = MethodSerializer _ -> Nothing } -unwrapAnnounceResponse :: Maybe NodeId -> NodeInfo -> AnnounceResponse -> ([NodeInfo], [Rendezvous], Maybe Nonce32) -unwrapAnnounceResponse alias ni (AnnounceResponse is_stored (SendNodes ns0)) | let ns = map udpNodeInfo ns0 - = case is_stored of - NotStored n32 -> ( ns , [] , Just n32) - SendBackKey k -> ( ns , [Rendezvous k ni] , Nothing ) - Acknowledged n32 -> ( ns , maybeToList $ fmap (\k -> Rendezvous (id2key k) ni) alias , Just n32) - -- TODO Announce key to announce peers. -- -- Announce Peers are only put in the 8 closest peers array if they respond -- cgit v1.2.3