summaryrefslogtreecommitdiff
path: root/src/Network/Tox/DHT
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2018-05-28 00:07:51 -0400
committerjoe <joe@jerkface.net>2018-05-28 00:07:51 -0400
commit5a1f5550a9135894993cf323ca4970f7c8470991 (patch)
tree9254504ff292488875ae61d90add3e58c6036b15 /src/Network/Tox/DHT
parent71e8bb90614ebd849b72c1ec1192f4a875c90f84 (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')
-rw-r--r--src/Network/Tox/DHT/Transport.hs3
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)
38import qualified Crypto.Tox as ToxCrypto 38import qualified Crypto.Tox as ToxCrypto
39import Network.QueryResponse 39import Network.QueryResponse
40 40
41import Control.Applicative
41import Control.Arrow 42import Control.Arrow
42import Control.Concurrent.STM 43import Control.Concurrent.STM
43import Control.Monad 44import 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)