summaryrefslogtreecommitdiff
path: root/dht/ToxManager.hs
diff options
context:
space:
mode:
Diffstat (limited to 'dht/ToxManager.hs')
-rw-r--r--dht/ToxManager.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/dht/ToxManager.hs b/dht/ToxManager.hs
index ab73b327..00e7146b 100644
--- a/dht/ToxManager.hs
+++ b/dht/ToxManager.hs
@@ -17,6 +17,7 @@ import Control.Monad
17import Crypto.Tox 17import Crypto.Tox
18import Data.Bits 18import Data.Bits
19import qualified Data.ByteArray as BA 19import qualified Data.ByteArray as BA
20import Data.Dependent.Sum
20import Data.Function 21import Data.Function
21import qualified Data.HashMap.Strict as HashMap 22import qualified Data.HashMap.Strict as HashMap
22import Data.List 23import Data.List
@@ -27,6 +28,7 @@ import qualified Data.Set as Set
27import qualified Data.Text as T 28import qualified Data.Text as T
28 ;import Data.Text (Text) 29 ;import Data.Text (Text)
29import Data.Time.Clock.POSIX 30import Data.Time.Clock.POSIX
31import qualified Data.Tox.DHT.Multi as Multi
30import Data.Word 32import Data.Word
31import DPut 33import DPut
32import DebugTag 34import DebugTag
@@ -341,7 +343,7 @@ gotDhtPubkey theirDhtKey tx theirKey = do
341 showak :: AnnounceKey -> String 343 showak :: AnnounceKey -> String
342 showak k = unpackAnnounceKey (txAnnouncer tx) k 344 showak k = unpackAnnounceKey (txAnnouncer tx) k
343 345
344 assume :: AnnounceKey -> POSIXTime -> SockAddr -> NodeInfo -> STM () 346 assume :: Show infosource => AnnounceKey -> POSIXTime -> infosource -> NodeInfo -> STM ()
345 assume akey time addr ni = 347 assume akey time addr ni =
346 tput XNodeinfoSearch $ show ("rumor", showak akey, time, addr, ni) 348 tput XNodeinfoSearch $ show ("rumor", showak akey, time, addr, ni)
347 349
@@ -419,9 +421,9 @@ getCookie tx theirKey theirDhtKey ni isActive getC ann akey now = getCookieAgain
419 421
420 callRealShakeHands cookie = do 422 callRealShakeHands cookie = do
421 forM_ (nodeInfo (key2id $ dhtpk theirDhtKey) (nodeAddr ni)) $ \ni' -> do 423 forM_ (nodeInfo (key2id $ dhtpk theirDhtKey) (nodeAddr ni)) $ \ni' -> do
422 hs <- cacheHandshake hscache (userSecret (txAccount tx)) theirKey ni' cookie 424 hs <- cacheHandshake hscache (userSecret (txAccount tx)) theirKey (Multi.UDP ==> ni') cookie
423 dput XNetCrypto $ show addr ++ "<-- handshake " ++ show (key2id theirKey) 425 dput XNetCrypto $ show addr ++ "<-- handshake " ++ show (key2id theirKey)
424 sendMessage (toxHandshakes $ txTox tx) (nodeAddr ni) hs 426 sendMessage (toxHandshakes $ txTox tx) (Multi.SessionUDP ==> nodeAddr ni) hs
425 427
426 reschedule n f = scheduleRel ann akey f n 428 reschedule n f = scheduleRel ann akey f n
427 reschedule' n f = reschedule n (ScheduledItem $ \_ _ now -> f now) 429 reschedule' n f = reschedule n (ScheduledItem $ \_ _ now -> f now)
@@ -433,7 +435,7 @@ getCookie tx theirKey theirDhtKey ni isActive getC ann akey now = getCookieAgain
433 dput XNetCrypto $ show addr ++ " <-- request cookie" 435 dput XNetCrypto $ show addr ++ " <-- request cookie"
434 let pending flag = setPendingCookie hscache myPublicKey theirKey flag 436 let pending flag = setPendingCookie hscache myPublicKey theirKey flag
435 atomically $ pending True 437 atomically $ pending True
436 cookieRequest (toxCryptoKeys $ txTox tx) (toxDHT $ txTox tx) myPublicKey ni >>= \case 438 cookieRequest (toxCryptoKeys $ txTox tx) (toxDHT $ txTox tx) myPublicKey (Multi.UDP ==> ni) >>= \case
437 Nothing -> atomically $ do 439 Nothing -> atomically $ do
438 pending False 440 pending False
439 reschedule' 5 (const getCookieAgain) 441 reschedule' 5 (const getCookieAgain)