diff options
author | Joe Crayne <joe@jerkface.net> | 2020-01-28 00:59:36 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-28 01:00:13 -0500 |
commit | 6339073a292cac1885f75b659b533ccb294a08bc (patch) | |
tree | aedbcf3403b54a3d13fb4bb626ffa27414c9c89f | |
parent | 3581bb6d887728441d161765392a0d96ae8ccf19 (diff) |
Debug prints putRendezvous related debug prints.
-rw-r--r-- | dht/Announcer/Tox.hs | 13 | ||||
-rw-r--r-- | dht/src/DebugTag.hs | 1 | ||||
-rw-r--r-- | dht/src/Network/Tox/Crypto/Transport.hs | 2 | ||||
-rw-r--r-- | dht/src/Network/Tox/Onion/Handlers.hs | 1 |
4 files changed, 16 insertions, 1 deletions
diff --git a/dht/Announcer/Tox.hs b/dht/Announcer/Tox.hs index 38e5bbfa..58b6621b 100644 --- a/dht/Announcer/Tox.hs +++ b/dht/Announcer/Tox.hs | |||
@@ -13,6 +13,8 @@ module Announcer.Tox where | |||
13 | import Announcer | 13 | import Announcer |
14 | import qualified Data.MinMaxPSQ as MM | 14 | import qualified Data.MinMaxPSQ as MM |
15 | import Data.Wrapper.PSQ as PSQ | 15 | import Data.Wrapper.PSQ as PSQ |
16 | import DebugTag | ||
17 | import DPut | ||
16 | import Network.Kademlia.Search | 18 | import Network.Kademlia.Search |
17 | 19 | ||
18 | import Control.Concurrent.Lifted.Instrument | 20 | import Control.Concurrent.Lifted.Instrument |
@@ -36,6 +38,7 @@ data AnnounceState = forall nid addr tok ni r qk. AnnounceState | |||
36 | -- a Kademlia network. | 38 | -- a Kademlia network. |
37 | data AnnounceMethod r = forall nid ni sr addr tok a qk. | 39 | data AnnounceMethod r = forall nid ni sr addr tok a qk. |
38 | ( Show nid | 40 | ( Show nid |
41 | , Show ni | ||
39 | , Hashable nid | 42 | , Hashable nid |
40 | , Hashable ni | 43 | , Hashable ni |
41 | , Ord addr | 44 | , Ord addr |
@@ -175,11 +178,21 @@ scheduleAnnounce announcer k AnnounceMethod{aSearch,aPublish,aNearestNodes,aTar | |||
175 | nq <- readTVar ns | 178 | nq <- readTVar ns |
176 | return $ filter (\(Binding ni _ _) -> not $ isJust $ MM.lookup' ni nq) | 179 | return $ filter (\(Binding ni _ _) -> not $ isJust $ MM.lookup' ni nq) |
177 | $ MM.toList bs | 180 | $ MM.toList bs |
181 | let ns = map (\(Binding ni mtok _) -> ni) is | ||
182 | dput XPublish $ unlines $ "Announcing to nodes of finished search." | ||
183 | : map (mappend " " . show) ns | ||
178 | publishToNodes is | 184 | publishToNodes is |
179 | putMVar mutex () | 185 | putMVar mutex () |
180 | Nothing -> do | 186 | Nothing -> do |
181 | -- Previous search did not finish. Instead of starting a new search, | 187 | -- Previous search did not finish. Instead of starting a new search, |
182 | -- we will re-announce only. | 188 | -- we will re-announce only. |
189 | do | ||
190 | is <- atomically $ do | ||
191 | bs <- readTVar (searchInformant st {- :: TVar (MinMaxPSQ' ni nid tok -}) | ||
192 | return $ MM.toList bs | ||
193 | let ns = map (\(Binding ni mtok _) -> ni) is | ||
194 | dput XPublish $ unlines $ "Announcing to nodes of in-progress search." | ||
195 | : map (mappend " " . show) ns | ||
183 | announce | 196 | announce |
184 | -- Cancel search so that a new one can start in the nest period. | 197 | -- Cancel search so that a new one can start in the nest period. |
185 | atomically $ searchCancel st | 198 | atomically $ searchCancel st |
diff --git a/dht/src/DebugTag.hs b/dht/src/DebugTag.hs index b5f862dc..8c1a7e3a 100644 --- a/dht/src/DebugTag.hs +++ b/dht/src/DebugTag.hs | |||
@@ -5,6 +5,7 @@ import Data.Typeable | |||
5 | -- | Debug Tags, add more as needed, but ensure XAnnounce is always first, XMisc last | 5 | -- | Debug Tags, add more as needed, but ensure XAnnounce is always first, XMisc last |
6 | data DebugTag | 6 | data DebugTag |
7 | = XAnnounce | 7 | = XAnnounce |
8 | | XPublish | ||
8 | | XAnnounceResponse | 9 | | XAnnounceResponse |
9 | | XBitTorrent | 10 | | XBitTorrent |
10 | | XDBus | 11 | | XDBus |
diff --git a/dht/src/Network/Tox/Crypto/Transport.hs b/dht/src/Network/Tox/Crypto/Transport.hs index 127b2dac..cff4fd88 100644 --- a/dht/src/Network/Tox/Crypto/Transport.hs +++ b/dht/src/Network/Tox/Crypto/Transport.hs | |||
@@ -103,7 +103,7 @@ encodeCrypto (x,saddr) = Just (B.cons 0x1b (runPut $ put x),saddr) | |||
103 | 103 | ||
104 | parseHandshakes :: ByteString -> addr -> Either String (Handshake Encrypted, addr) | 104 | parseHandshakes :: ByteString -> addr -> Either String (Handshake Encrypted, addr) |
105 | parseHandshakes (B.uncons -> Just (0x1a,pkt)) saddr = left ("parseHandshakes: "++) $ (,saddr) <$> runGet get pkt | 105 | parseHandshakes (B.uncons -> Just (0x1a,pkt)) saddr = left ("parseHandshakes: "++) $ (,saddr) <$> runGet get pkt |
106 | parseHandshakes bs _ = Left $ "parseHandshakes_: " ++ show (B.unpack $ B.take 1 bs) | 106 | parseHandshakes bs _ = Left $ "Unhandled packet: " ++ show (B.unpack $ B.take 1 bs) |
107 | 107 | ||
108 | encodeHandshakes :: Handshake Encrypted -> addr -> (ByteString, addr) | 108 | encodeHandshakes :: Handshake Encrypted -> addr -> (ByteString, addr) |
109 | encodeHandshakes x saddr = (B.cons 0x1a (runPut $ put x),saddr) | 109 | encodeHandshakes x saddr = (B.cons 0x1a (runPut $ put x),saddr) |
diff --git a/dht/src/Network/Tox/Onion/Handlers.hs b/dht/src/Network/Tox/Onion/Handlers.hs index ca7d47db..bd441f06 100644 --- a/dht/src/Network/Tox/Onion/Handlers.hs +++ b/dht/src/Network/Tox/Onion/Handlers.hs | |||
@@ -373,6 +373,7 @@ putRendezvous getTimeout crypto client pubkey nonce32 ni = do | |||
373 | rendezvousKey = key2id rkey | 373 | rendezvousKey = key2id rkey |
374 | asel <- atomically $ selectAlias crypto longTermKey | 374 | asel <- atomically $ selectAlias crypto longTermKey |
375 | let oaddr = OnionDestination asel ni Nothing | 375 | let oaddr = OnionDestination asel ni Nothing |
376 | dput XPublish $ "putRendezvous at " ++ show ni | ||
376 | fmap resultToMaybe | 377 | fmap resultToMaybe |
377 | $ sendOnion getTimeout client (AnnounceRequest nonce32 longTermKey rendezvousKey) oaddr | 378 | $ sendOnion getTimeout client (AnnounceRequest nonce32 longTermKey rendezvousKey) oaddr |
378 | $ \ni resp -> (Rendezvous rkey ni, resp) | 379 | $ \ni resp -> (Rendezvous rkey ni, resp) |