diff options
author | Joe Crayne <joe@jerkface.net> | 2020-01-15 20:15:57 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-16 00:15:27 -0500 |
commit | 14de512e24922a9fc2c97ecea30011380ed2fad5 (patch) | |
tree | d9974383e2473ad5d0cefe09912e1aca4bcabe3c | |
parent | 32a9be9211583f8405e92ecc1158f035141820be (diff) |
Reverted c3866287: we want to use DHT-key, not the toxid.
-rw-r--r-- | dht/ToxManager.hs | 2 | ||||
-rw-r--r-- | dht/examples/dhtd.hs | 6 | ||||
-rw-r--r-- | 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 | |||
646 | let meth = SearchMethod (toxQSearch tox) onResult (nearNodes tox) (key2id them) 30 | 646 | let meth = SearchMethod (toxQSearch tox) onResult (nearNodes tox) (key2id them) 30 |
647 | where | 647 | where |
648 | onResult theirkey rendezvous = do | 648 | onResult theirkey rendezvous = do |
649 | dkey <- Tox.getContactInfo (Just (txTCP tx,them)) tox | 649 | dkey <- Tox.getContactInfo tox |
650 | let tr = Tox.toxToRoute tox | 650 | let tr = Tox.toxToRoute tox |
651 | route = Tox.AnnouncedRendezvous theirkey rendezvous | 651 | route = Tox.AnnouncedRendezvous theirkey rendezvous |
652 | dput XMan $ unwords [ take 8 (show $ key2id theirkey) | 652 | 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 | |||
1589 | -- | 1589 | -- |
1590 | -- > a +dhtkey KWoEx1XQHrluIoW.3nK6BFb6XCebKWr3nDDt3V7CcoJ | 1590 | -- > a +dhtkey KWoEx1XQHrluIoW.3nK6BFb6XCebKWr3nDDt3V7CcoJ |
1591 | , ("dhtkey", DHTAnnouncable { announceSendData = Left ("toxid", readEither, \me them addr -> do | 1591 | , ("dhtkey", DHTAnnouncable { announceSendData = Left ("toxid", readEither, \me them addr -> do |
1592 | -- let mthem = Just ( TCP.tcpClient | 1592 | dkey <- Tox.getContactInfo tox |
1593 | -- $ tcpKademliaClient | ||
1594 | -- $ toxOnionRoutes tox | ||
1595 | -- , them ) | ||
1596 | dkey <- Tox.getContactInfo Nothing tox | ||
1597 | sendMessage | 1593 | sendMessage |
1598 | (Tox.toxToRoute tox) | 1594 | (Tox.toxToRoute tox) |
1599 | (Tox.AnnouncedRendezvous them addr) | 1595 | (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 | |||
72 | import Network.Tox.RelayPinger | 72 | import Network.Tox.RelayPinger |
73 | import System.Global6 | 73 | import System.Global6 |
74 | import Network.Tox.Transport | 74 | import Network.Tox.Transport |
75 | import Network.Tox.TCP (tcpClient, RelayClient) | 75 | import Network.Tox.TCP (tcpClient) |
76 | import Network.Tox.Onion.Routes | 76 | import Network.Tox.Onion.Routes |
77 | import Network.Tox.ContactInfo | 77 | import Network.Tox.ContactInfo |
78 | import Text.XXD | 78 | import Text.XXD |
@@ -199,8 +199,8 @@ data Tox extra = Tox | |||
199 | 199 | ||
200 | 200 | ||
201 | -- | Create a DHTPublicKey packet to send to a remote contact. | 201 | -- | Create a DHTPublicKey packet to send to a remote contact. |
202 | getContactInfo :: Maybe (RelayClient,PublicKey) -> Tox extra -> IO DHT.DHTPublicKey | 202 | getContactInfo :: Tox extra -> IO DHT.DHTPublicKey |
203 | getContactInfo mthem Tox{toxCryptoKeys,toxRouting,toxOnionRoutes} = join $ atomically $ do | 203 | getContactInfo Tox{toxCryptoKeys,toxRouting,toxOnionRoutes} = join $ atomically $ do |
204 | (rcnt,relays) <- currentRelays (tcpRelayPinger toxOnionRoutes) | 204 | (rcnt,relays) <- currentRelays (tcpRelayPinger toxOnionRoutes) |
205 | r4 <- readTVar $ DHT.routing4 toxRouting | 205 | r4 <- readTVar $ DHT.routing4 toxRouting |
206 | r6 <- readTVar $ DHT.routing6 toxRouting | 206 | r6 <- readTVar $ DHT.routing6 toxRouting |
@@ -212,16 +212,12 @@ getContactInfo mthem Tox{toxCryptoKeys,toxRouting,toxOnionRoutes} = join $ atomi | |||
212 | n6s = R.kclosest DHT.toxSpace 4 self r6 | 212 | n6s = R.kclosest DHT.toxSpace 4 self r6 |
213 | ns = filter (DHT.isGlobal . nodeIP) [n4,n6] | 213 | ns = filter (DHT.isGlobal . nodeIP) [n4,n6] |
214 | ++ concat (zipWith (\a b -> [a,b]) n4s n6s) | 214 | ++ concat (zipWith (\a b -> [a,b]) n4s n6s) |
215 | sending_ns = take 4 $ relays ++ map TCP.fromUDPNode ns | ||
216 | return $ do | 215 | return $ do |
217 | forM_ mthem $ \(tcp,them) -> | ||
218 | forM_ (filter (\n -> TCP.tcpPort n /= 0) sending_ns) $ \ni -> do | ||
219 | Multi.tcpConnectionRequest tcp them ni | ||
220 | timestamp <- round . (* 1000000) <$> getPOSIXTime | 216 | timestamp <- round . (* 1000000) <$> getPOSIXTime |
221 | return DHT.DHTPublicKey | 217 | return DHT.DHTPublicKey |
222 | { dhtpkNonce = timestamp | 218 | { dhtpkNonce = timestamp |
223 | , dhtpk = id2key self | 219 | , dhtpk = id2key self |
224 | , dhtpkNodes = DHT.SendNodes sending_ns | 220 | , dhtpkNodes = DHT.SendNodes $ take 4 $ relays ++ map TCP.fromUDPNode ns |
225 | } | 221 | } |
226 | 222 | ||
227 | isLocalHost :: SockAddr -> Bool | 223 | isLocalHost :: SockAddr -> Bool |