diff options
author | Joe Crayne <joe@jerkface.net> | 2019-12-14 16:11:03 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-01 23:26:49 -0500 |
commit | d5efdc327bbb69a905043df45415817e318e38ee (patch) | |
tree | 7be975048f3e40c27811bdb39ba92d871a42588c /dht/src/Network/Tox/Onion/Handlers.hs | |
parent | 8c04d9cca70241bebe4b94b779fe7bbfe6140f51 (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.hs | 11 |
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 #-} |
4 | module Network.Tox.Onion.Handlers where | 4 | module Network.Tox.Onion.Handlers where |
5 | 5 | ||
6 | import qualified Data.Tox.DHT.Multi as Multi | ||
6 | import Network.Kademlia.Search | 7 | import Network.Kademlia.Search |
7 | import Network.Tox.TCP.NodeId (udpNodeInfo) | 8 | import Network.Tox.TCP.NodeId (udpNodeInfo) |
8 | import Network.Tox.DHT.Transport | 9 | import Network.Tox.DHT.Transport |
@@ -29,6 +30,7 @@ import Control.Concurrent | |||
29 | import GHC.Conc (labelThread) | 30 | import GHC.Conc (labelThread) |
30 | #endif | 31 | #endif |
31 | import Control.Concurrent.STM | 32 | import Control.Concurrent.STM |
33 | import Data.Dependent.Sum ( (==>) ) | ||
32 | import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime) | 34 | import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime) |
33 | import Network.Socket | 35 | import 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 | ||
254 | unwrapAnnounceResponse :: Maybe NodeId -> NodeInfo -> AnnounceResponse -> ([NodeInfo], [Rendezvous], Maybe Nonce32) | ||
255 | unwrapAnnounceResponse 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 |