diff options
Diffstat (limited to 'src/Network/Tox')
-rw-r--r-- | src/Network/Tox/Crypto/Handlers.hs | 4 | ||||
-rw-r--r-- | src/Network/Tox/DHT/Handlers.hs | 17 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs index bffb4280..0e349196 100644 --- a/src/Network/Tox/Crypto/Handlers.hs +++ b/src/Network/Tox/Crypto/Handlers.hs | |||
@@ -7,7 +7,7 @@ import Network.QueryResponse | |||
7 | import Network.Tox.NodeId | 7 | import Network.Tox.NodeId |
8 | import Network.Tox.Crypto.Transport | 8 | import Network.Tox.Crypto.Transport |
9 | import Network.Tox.DHT.Transport (Cookie(..),CookieData(..), CookieRequest(..), NoSpam(..)) | 9 | import Network.Tox.DHT.Transport (Cookie(..),CookieData(..), CookieRequest(..), NoSpam(..)) |
10 | import Network.Tox.DHT.Handlers (Client, cookieRequest, cookieRequestH ) | 10 | import Network.Tox.DHT.Handlers (Client, cookieRequest, createCookie ) |
11 | import Crypto.Tox | 11 | import Crypto.Tox |
12 | import Control.Concurrent.STM | 12 | import Control.Concurrent.STM |
13 | import Network.Address | 13 | import Network.Address |
@@ -212,7 +212,7 @@ newHandShakeData crypto basenonce (HParam {hpOtherCookie,hpMySecretKey,hpCookieR | |||
212 | = do | 212 | = do |
213 | freshCookie | 213 | freshCookie |
214 | <- case nodeInfo (key2id hpCookieRemoteDhtkey) addr of | 214 | <- case nodeInfo (key2id hpCookieRemoteDhtkey) addr of |
215 | Right nodeinfo -> Just <$> cookieRequestH crypto nodeinfo (CookieRequest hpCookieRemotePubkey) | 215 | Right nodeinfo -> Just <$> createCookie crypto nodeinfo hpCookieRemotePubkey |
216 | Left er -> return Nothing | 216 | Left er -> return Nothing |
217 | let hinit = hashInit | 217 | let hinit = hashInit |
218 | Cookie n24 encrypted = hpOtherCookie | 218 | Cookie n24 encrypted = hpOtherCookie |
diff --git a/src/Network/Tox/DHT/Handlers.hs b/src/Network/Tox/DHT/Handlers.hs index 9faee69a..327659a9 100644 --- a/src/Network/Tox/DHT/Handlers.hs +++ b/src/Network/Tox/DHT/Handlers.hs | |||
@@ -217,11 +217,8 @@ getNodesH routing addr (GetNodes nid) = do | |||
217 | 217 | ||
218 | k = 4 | 218 | k = 4 |
219 | 219 | ||
220 | cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO Cookie | 220 | createCookie :: TransportCrypto -> NodeInfo -> PublicKey -> IO Cookie |
221 | cookieRequestH crypto ni (CookieRequest remoteUserKey) = do | 221 | createCookie crypto ni remoteUserKey = do |
222 | hPutStrLn stderr $ unlines | ||
223 | [ "CookieRequest! remoteUserKey=" ++ show (key2id remoteUserKey) | ||
224 | , " sender=" ++ show ni ] | ||
225 | (n24,sym,us) <- atomically $ do | 222 | (n24,sym,us) <- atomically $ do |
226 | n24 <- transportNewNonce crypto | 223 | n24 <- transportNewNonce crypto |
227 | sym <- transportSymmetric crypto | 224 | sym <- transportSymmetric crypto |
@@ -234,9 +231,17 @@ cookieRequestH crypto ni (CookieRequest remoteUserKey) = do | |||
234 | , dhtKey = transportPublic crypto | 231 | , dhtKey = transportPublic crypto |
235 | } | 232 | } |
236 | edta = encryptSymmetric sym n24 dta | 233 | edta = encryptSymmetric sym n24 dta |
237 | hPutStrLn stderr $ "CookieRequest! responding to " ++ show (key2id remoteUserKey) | ||
238 | return $ Cookie n24 edta | 234 | return $ Cookie n24 edta |
239 | 235 | ||
236 | cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO Cookie | ||
237 | cookieRequestH crypto ni (CookieRequest remoteUserKey) = do | ||
238 | hPutStrLn stderr $ unlines | ||
239 | [ "CookieRequest! remoteUserKey=" ++ show (key2id remoteUserKey) | ||
240 | , " sender=" ++ show ni ] | ||
241 | x <- createCookie crypto ni remoteUserKey | ||
242 | hPutStrLn stderr $ "CookieRequest! responding to " ++ show (key2id remoteUserKey) | ||
243 | return x | ||
244 | |||
240 | lanDiscoveryH :: Client -> NodeInfo -> NodeInfo -> IO (Maybe (Message -> Message)) | 245 | lanDiscoveryH :: Client -> NodeInfo -> NodeInfo -> IO (Maybe (Message -> Message)) |
241 | lanDiscoveryH client _ ni = do | 246 | lanDiscoveryH client _ ni = do |
242 | forkIO $ do | 247 | forkIO $ do |