diff options
author | Andrew Cady <d@jerkface.net> | 2018-06-24 05:02:34 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2018-06-24 06:40:09 -0400 |
commit | c781c88c3cd77b70694a26c3f27ff82aa6fa65d3 (patch) | |
tree | 02b8e3635677f073eb959a8f6224e98ad85993ac /Connection | |
parent | 4c045e987892a0b32d86a93f0f521f497213341e (diff) |
Fixed handshake behavior
The handshake code would flood the network with interminable handshakes.
Diffstat (limited to 'Connection')
-rw-r--r-- | Connection/Tox.hs | 8 | ||||
-rw-r--r-- | Connection/Tox/Threads.hs | 6 |
2 files changed, 7 insertions, 7 deletions
diff --git a/Connection/Tox.hs b/Connection/Tox.hs index 3f5f7e2c..9612f1e5 100644 --- a/Connection/Tox.hs +++ b/Connection/Tox.hs | |||
@@ -193,12 +193,12 @@ setToxPolicy params conmap k@(Key me them) policy = do | |||
193 | registerNodeCallback routing $ NodeInfoCallback | 193 | registerNodeCallback routing $ NodeInfoCallback |
194 | { interestingNodeId = nid | 194 | { interestingNodeId = nid |
195 | , listenerId = callbackId | 195 | , listenerId = callbackId |
196 | , observedAddress = \now ni -> writeTVar (contactLastSeenAddr c) (Just (now,nodeAddr ni)) | 196 | , observedAddress = \now ni -> writeTVar (contactLastSeenAddr c) (Just (now, ni)) |
197 | , rumoredAddress = \now saddr ni -> do | 197 | , rumoredAddress = \now saddr ni -> do |
198 | m <- readTVar (contactLastSeenAddr c) | 198 | m <- readTVar (contactLastSeenAddr c) |
199 | -- TODO remember information source and handle multiple rumors. | 199 | -- TODO remember information source and handle multiple rumors. |
200 | case m of Just _ -> return () | 200 | case m of Just _ -> return () |
201 | Nothing -> writeTVar (contactLastSeenAddr c) (Just (now,nodeAddr ni)) | 201 | Nothing -> writeTVar (contactLastSeenAddr c) (Just (now, ni)) |
202 | } | 202 | } |
203 | return () | 203 | return () |
204 | RefusingToConnect -> do -- disconnect or cancel any pending connection | 204 | RefusingToConnect -> do -- disconnect or cancel any pending connection |
@@ -235,12 +235,12 @@ setToxPolicy params conmap k@(Key me them) policy = do | |||
235 | registerNodeCallback routing $ NodeInfoCallback | 235 | registerNodeCallback routing $ NodeInfoCallback |
236 | { interestingNodeId = nid | 236 | { interestingNodeId = nid |
237 | , listenerId = callbackId | 237 | , listenerId = callbackId |
238 | , observedAddress = \now ni -> writeTVar (contactLastSeenAddr c) (Just (now,nodeAddr ni)) | 238 | , observedAddress = \now ni -> writeTVar (contactLastSeenAddr c) (Just (now, ni)) |
239 | , rumoredAddress = \now saddr ni -> do | 239 | , rumoredAddress = \now saddr ni -> do |
240 | m <- readTVar (contactLastSeenAddr c) | 240 | m <- readTVar (contactLastSeenAddr c) |
241 | -- TODO remember information source and handle multiple rumors. | 241 | -- TODO remember information source and handle multiple rumors. |
242 | case m of Just _ -> return () | 242 | case m of Just _ -> return () |
243 | Nothing -> writeTVar (contactLastSeenAddr c) (Just (now,nodeAddr ni)) | 243 | Nothing -> writeTVar (contactLastSeenAddr c) (Just (now, ni)) |
244 | } | 244 | } |
245 | 245 | ||
246 | stringToKey_ :: String -> Maybe Key | 246 | stringToKey_ :: String -> Maybe Key |
diff --git a/Connection/Tox/Threads.hs b/Connection/Tox/Threads.hs index ba49b7dc..de719655 100644 --- a/Connection/Tox/Threads.hs +++ b/Connection/Tox/Threads.hs | |||
@@ -140,7 +140,7 @@ pursueContact getPolicy getStatus PursueContactMethods{..} statusVar = do | |||
140 | (do | 140 | (do |
141 | (stamp_theirDhtKey,theirDhtKey) <- second DHT.dhtpk <$> retryUntilJust (contactKeyPacket contact) | 141 | (stamp_theirDhtKey,theirDhtKey) <- second DHT.dhtpk <$> retryUntilJust (contactKeyPacket contact) |
142 | (stamp_saddr,saddr) <- retryUntilJust (contactLastSeenAddr contact) | 142 | (stamp_saddr,saddr) <- retryUntilJust (contactLastSeenAddr contact) |
143 | ni <- either (const retry) return $ nodeInfo (key2id theirDhtKey) saddr | 143 | ni <- either (const retry) return $ nodeInfo (key2id theirDhtKey) (_fixme saddr) |
144 | return $ do | 144 | return $ do |
145 | -- AcquiringCookie | 145 | -- AcquiringCookie |
146 | atomically $ writeTVar statusVar (InProgress AcquiringCookie) | 146 | atomically $ writeTVar statusVar (InProgress AcquiringCookie) |
@@ -166,11 +166,11 @@ pursueContact getPolicy getStatus PursueContactMethods{..} statusVar = do | |||
166 | newsession <- generateSecretKey | 166 | newsession <- generateSecretKey |
167 | timestamp <- getPOSIXTime | 167 | timestamp <- getPOSIXTime |
168 | (myhandshake,ioAction) | 168 | (myhandshake,ioAction) |
169 | <- atomically $ freshCryptoSession allsessions saddr newsession timestamp hp | 169 | <- atomically $ freshCryptoSession allsessions (_fixme saddr) newsession timestamp hp |
170 | ioAction | 170 | ioAction |
171 | -- send handshake | 171 | -- send handshake |
172 | forM myhandshake $ \response_handshake -> do | 172 | forM myhandshake $ \response_handshake -> do |
173 | sendHandshake allsessions saddr response_handshake | 173 | sendHandshake allsessions (_fixme saddr) response_handshake |
174 | atomically $ writeTVar statusVar $ InProgress AwaitingHandshake | 174 | atomically $ writeTVar statusVar $ InProgress AwaitingHandshake |
175 | return shortRetryInterval | 175 | return shortRetryInterval |
176 | -- AwaitingHandshake | 176 | -- AwaitingHandshake |