diff options
author | joe <joe@jerkface.net> | 2018-05-28 00:07:51 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2018-05-28 00:07:51 -0400 |
commit | 5a1f5550a9135894993cf323ca4970f7c8470991 (patch) | |
tree | 9254504ff292488875ae61d90add3e58c6036b15 /src/Network/Tox/DHT/Transport.hs | |
parent | 71e8bb90614ebd849b72c1ec1192f4a875c90f84 (diff) |
Use first known key for cookie response if wrong ip address.
This isn't fool-proof, but it enables some testing scenarios
where the ip address was not the expected one.
Diffstat (limited to 'src/Network/Tox/DHT/Transport.hs')
-rw-r--r-- | src/Network/Tox/DHT/Transport.hs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Network/Tox/DHT/Transport.hs b/src/Network/Tox/DHT/Transport.hs index 7af8d408..f7feea3b 100644 --- a/src/Network/Tox/DHT/Transport.hs +++ b/src/Network/Tox/DHT/Transport.hs | |||
@@ -38,6 +38,7 @@ import Crypto.Tox hiding (encrypt,decrypt) | |||
38 | import qualified Crypto.Tox as ToxCrypto | 38 | import qualified Crypto.Tox as ToxCrypto |
39 | import Network.QueryResponse | 39 | import Network.QueryResponse |
40 | 40 | ||
41 | import Control.Applicative | ||
41 | import Control.Arrow | 42 | import Control.Arrow |
42 | import Control.Concurrent.STM | 43 | import Control.Concurrent.STM |
43 | import Control.Monad | 44 | import Control.Monad |
@@ -108,7 +109,7 @@ parseDHTAddr crypto (msg,saddr) | |||
108 | 0x19 -> do | 109 | 0x19 -> do |
109 | cs <- atomically $ readTVar (pendingCookies crypto) | 110 | cs <- atomically $ readTVar (pendingCookies crypto) |
110 | let ni = fromMaybe (noReplyAddr saddr) $ do | 111 | let ni = fromMaybe (noReplyAddr saddr) $ do |
111 | (cnt,key) <- lookup saddr cs | 112 | (cnt,key) <- lookup saddr cs <|> listToMaybe (map snd cs) |
112 | either (const Nothing) Just $ nodeInfo (key2id key) saddr | 113 | either (const Nothing) Just $ nodeInfo (key2id key) saddr |
113 | left $ fanGet bs getCookie (uncurry DHTCookie) (const $ ni) | 114 | left $ fanGet bs getCookie (uncurry DHTCookie) (const $ ni) |
114 | 0x20 -> left $ fanGet bs getDHTReqest (uncurry DHTDHTRequest) (asymNodeInfo saddr . snd) | 115 | 0x20 -> left $ fanGet bs getDHTReqest (uncurry DHTDHTRequest) (asymNodeInfo saddr . snd) |