From 14de512e24922a9fc2c97ecea30011380ed2fad5 Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Wed, 15 Jan 2020 20:15:57 -0500 Subject: Reverted c3866287: we want to use DHT-key, not the toxid. --- dht/ToxManager.hs | 2 +- dht/examples/dhtd.hs | 6 +----- dht/src/Network/Tox.hs | 12 ++++-------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/dht/ToxManager.hs b/dht/ToxManager.hs index 733a0cdc..b0990430 100644 --- a/dht/ToxManager.hs +++ b/dht/ToxManager.hs @@ -646,7 +646,7 @@ startConnecting0 tx them contact reason = do let meth = SearchMethod (toxQSearch tox) onResult (nearNodes tox) (key2id them) 30 where onResult theirkey rendezvous = do - dkey <- Tox.getContactInfo (Just (txTCP tx,them)) tox + dkey <- Tox.getContactInfo tox let tr = Tox.toxToRoute tox route = Tox.AnnouncedRendezvous theirkey rendezvous dput XMan $ unwords [ take 8 (show $ key2id theirkey) diff --git a/dht/examples/dhtd.hs b/dht/examples/dhtd.hs index 5bf9296e..f4d04761 100644 --- a/dht/examples/dhtd.hs +++ b/dht/examples/dhtd.hs @@ -1589,11 +1589,7 @@ initTox runio opts ssvar keysdb mbxmpp invc = case porttox opts of -- -- > a +dhtkey KWoEx1XQHrluIoW.3nK6BFb6XCebKWr3nDDt3V7CcoJ , ("dhtkey", DHTAnnouncable { announceSendData = Left ("toxid", readEither, \me them addr -> do - -- let mthem = Just ( TCP.tcpClient - -- $ tcpKademliaClient - -- $ toxOnionRoutes tox - -- , them ) - dkey <- Tox.getContactInfo Nothing tox + dkey <- Tox.getContactInfo tox sendMessage (Tox.toxToRoute tox) (Tox.AnnouncedRendezvous them addr) diff --git a/dht/src/Network/Tox.hs b/dht/src/Network/Tox.hs index fca0f9e0..f136ab96 100644 --- a/dht/src/Network/Tox.hs +++ b/dht/src/Network/Tox.hs @@ -72,7 +72,7 @@ import qualified Network.Tox.Onion.Transport as Onion import Network.Tox.RelayPinger import System.Global6 import Network.Tox.Transport -import Network.Tox.TCP (tcpClient, RelayClient) +import Network.Tox.TCP (tcpClient) import Network.Tox.Onion.Routes import Network.Tox.ContactInfo import Text.XXD @@ -199,8 +199,8 @@ data Tox extra = Tox -- | Create a DHTPublicKey packet to send to a remote contact. -getContactInfo :: Maybe (RelayClient,PublicKey) -> Tox extra -> IO DHT.DHTPublicKey -getContactInfo mthem Tox{toxCryptoKeys,toxRouting,toxOnionRoutes} = join $ atomically $ do +getContactInfo :: Tox extra -> IO DHT.DHTPublicKey +getContactInfo Tox{toxCryptoKeys,toxRouting,toxOnionRoutes} = join $ atomically $ do (rcnt,relays) <- currentRelays (tcpRelayPinger toxOnionRoutes) r4 <- readTVar $ DHT.routing4 toxRouting r6 <- readTVar $ DHT.routing6 toxRouting @@ -212,16 +212,12 @@ getContactInfo mthem Tox{toxCryptoKeys,toxRouting,toxOnionRoutes} = join $ atomi n6s = R.kclosest DHT.toxSpace 4 self r6 ns = filter (DHT.isGlobal . nodeIP) [n4,n6] ++ concat (zipWith (\a b -> [a,b]) n4s n6s) - sending_ns = take 4 $ relays ++ map TCP.fromUDPNode ns return $ do - forM_ mthem $ \(tcp,them) -> - forM_ (filter (\n -> TCP.tcpPort n /= 0) sending_ns) $ \ni -> do - Multi.tcpConnectionRequest tcp them ni timestamp <- round . (* 1000000) <$> getPOSIXTime return DHT.DHTPublicKey { dhtpkNonce = timestamp , dhtpk = id2key self - , dhtpkNodes = DHT.SendNodes sending_ns + , dhtpkNodes = DHT.SendNodes $ take 4 $ relays ++ map TCP.fromUDPNode ns } isLocalHost :: SockAddr -> Bool -- cgit v1.2.3