diff options
Diffstat (limited to 'dht/ToxManager.hs')
-rw-r--r-- | dht/ToxManager.hs | 10 |
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 | |||
17 | import Crypto.Tox | 17 | import Crypto.Tox |
18 | import Data.Bits | 18 | import Data.Bits |
19 | import qualified Data.ByteArray as BA | 19 | import qualified Data.ByteArray as BA |
20 | import Data.Dependent.Sum | ||
20 | import Data.Function | 21 | import Data.Function |
21 | import qualified Data.HashMap.Strict as HashMap | 22 | import qualified Data.HashMap.Strict as HashMap |
22 | import Data.List | 23 | import Data.List |
@@ -27,6 +28,7 @@ import qualified Data.Set as Set | |||
27 | import qualified Data.Text as T | 28 | import qualified Data.Text as T |
28 | ;import Data.Text (Text) | 29 | ;import Data.Text (Text) |
29 | import Data.Time.Clock.POSIX | 30 | import Data.Time.Clock.POSIX |
31 | import qualified Data.Tox.DHT.Multi as Multi | ||
30 | import Data.Word | 32 | import Data.Word |
31 | import DPut | 33 | import DPut |
32 | import DebugTag | 34 | import 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) |