diff options
Diffstat (limited to 'Connection')
-rw-r--r-- | Connection/Tox.hs | 12 | ||||
-rw-r--r-- | Connection/Tox/Threads.hs | 7 |
2 files changed, 10 insertions, 9 deletions
diff --git a/Connection/Tox.hs b/Connection/Tox.hs index 7b304050..0c2f281f 100644 --- a/Connection/Tox.hs +++ b/Connection/Tox.hs | |||
@@ -192,12 +192,12 @@ setToxPolicy params conmap k@(Key me them) policy = do | |||
192 | registerNodeCallback routing $ NodeInfoCallback | 192 | registerNodeCallback routing $ NodeInfoCallback |
193 | { interestingNodeId = nid | 193 | { interestingNodeId = nid |
194 | , listenerId = callbackId | 194 | , listenerId = callbackId |
195 | , observedAddress = \ni -> writeTVar (contactLastSeenAddr c) (Just $ nodeAddr ni) | 195 | , observedAddress = \now ni -> writeTVar (contactLastSeenAddr c) (Just (now,nodeAddr ni)) |
196 | , rumoredAddress = \saddr ni -> do | 196 | , rumoredAddress = \now saddr ni -> do |
197 | m <- readTVar (contactLastSeenAddr c) | 197 | m <- readTVar (contactLastSeenAddr c) |
198 | -- TODO remember information source and handle multiple rumors. | 198 | -- TODO remember information source and handle multiple rumors. |
199 | case m of Just _ -> return () | 199 | case m of Just _ -> return () |
200 | Nothing -> writeTVar (contactLastSeenAddr c) (Just $ nodeAddr ni) | 200 | Nothing -> writeTVar (contactLastSeenAddr c) (Just (now,nodeAddr ni)) |
201 | } | 201 | } |
202 | return () | 202 | return () |
203 | RefusingToConnect -> do -- disconnect or cancel any pending connection | 203 | RefusingToConnect -> do -- disconnect or cancel any pending connection |
@@ -234,12 +234,12 @@ setToxPolicy params conmap k@(Key me them) policy = do | |||
234 | registerNodeCallback routing $ NodeInfoCallback | 234 | registerNodeCallback routing $ NodeInfoCallback |
235 | { interestingNodeId = nid | 235 | { interestingNodeId = nid |
236 | , listenerId = callbackId | 236 | , listenerId = callbackId |
237 | , observedAddress = \ni -> writeTVar (contactLastSeenAddr c) (Just $ nodeAddr ni) | 237 | , observedAddress = \now ni -> writeTVar (contactLastSeenAddr c) (Just (now,nodeAddr ni)) |
238 | , rumoredAddress = \saddr ni -> do | 238 | , rumoredAddress = \now saddr ni -> do |
239 | m <- readTVar (contactLastSeenAddr c) | 239 | m <- readTVar (contactLastSeenAddr c) |
240 | -- TODO remember information source and handle multiple rumors. | 240 | -- TODO remember information source and handle multiple rumors. |
241 | case m of Just _ -> return () | 241 | case m of Just _ -> return () |
242 | Nothing -> writeTVar (contactLastSeenAddr c) (Just $ nodeAddr ni) | 242 | Nothing -> writeTVar (contactLastSeenAddr c) (Just (now,nodeAddr ni)) |
243 | } | 243 | } |
244 | 244 | ||
245 | stringToKey_ :: String -> Maybe Key | 245 | stringToKey_ :: String -> Maybe Key |
diff --git a/Connection/Tox/Threads.hs b/Connection/Tox/Threads.hs index 5602fa40..a5a839f9 100644 --- a/Connection/Tox/Threads.hs +++ b/Connection/Tox/Threads.hs | |||
@@ -32,6 +32,7 @@ import Control.Concurrent.Lifted | |||
32 | import GHC.Conc (labelThread) | 32 | import GHC.Conc (labelThread) |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | import Control.Arrow | ||
35 | import Control.Concurrent.STM | 36 | import Control.Concurrent.STM |
36 | import Control.Monad | 37 | import Control.Monad |
37 | import Data.Function | 38 | import Data.Function |
@@ -124,15 +125,15 @@ persueContact getPolicy getStatus PersueContactMethods{..} statusVar = do | |||
124 | $ \retryAfterTimeout -> | 125 | $ \retryAfterTimeout -> |
125 | orElse (do | 126 | orElse (do |
126 | readTVar statusVar >>= check . (/= InProgress AcquiringIPAddress) | 127 | readTVar statusVar >>= check . (/= InProgress AcquiringIPAddress) |
127 | theirDhtKey <- DHT.dhtpk <$> retryUntilJust (contactKeyPacket contact) | 128 | (stamp_theirDhtKey,theirDhtKey) <- second DHT.dhtpk <$> retryUntilJust (contactKeyPacket contact) |
128 | -- We don't have an IP address yet. | 129 | -- We don't have an IP address yet. |
129 | maybe (return ()) (const retry) =<< readTVar (contactLastSeenAddr contact) | 130 | maybe (return ()) (const retry) =<< readTVar (contactLastSeenAddr contact) |
130 | return $ do -- AcquiringIPAddress | 131 | return $ do -- AcquiringIPAddress |
131 | atomically $ writeTVar statusVar (InProgress AcquiringIPAddress) | 132 | atomically $ writeTVar statusVar (InProgress AcquiringIPAddress) |
132 | retryAfterTimeout 0) | 133 | retryAfterTimeout 0) |
133 | (do | 134 | (do |
134 | theirDhtKey <- DHT.dhtpk <$> retryUntilJust (contactKeyPacket contact) | 135 | (stamp_theirDhtKey,theirDhtKey) <- second DHT.dhtpk <$> retryUntilJust (contactKeyPacket contact) |
135 | saddr <- retryUntilJust (contactLastSeenAddr contact) | 136 | (stamp_saddr,saddr) <- retryUntilJust (contactLastSeenAddr contact) |
136 | ni <- either (const retry) return $ nodeInfo (key2id theirDhtKey) saddr | 137 | ni <- either (const retry) return $ nodeInfo (key2id theirDhtKey) saddr |
137 | return $ do | 138 | return $ do |
138 | -- AcquiringCookie | 139 | -- AcquiringCookie |