summaryrefslogtreecommitdiff
path: root/src/Network/Tox
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/Tox')
-rw-r--r--src/Network/Tox/Crypto/Handlers.hs4
-rw-r--r--src/Network/Tox/DHT/Handlers.hs17
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
7import Network.Tox.NodeId 7import Network.Tox.NodeId
8import Network.Tox.Crypto.Transport 8import Network.Tox.Crypto.Transport
9import Network.Tox.DHT.Transport (Cookie(..),CookieData(..), CookieRequest(..), NoSpam(..)) 9import Network.Tox.DHT.Transport (Cookie(..),CookieData(..), CookieRequest(..), NoSpam(..))
10import Network.Tox.DHT.Handlers (Client, cookieRequest, cookieRequestH ) 10import Network.Tox.DHT.Handlers (Client, cookieRequest, createCookie )
11import Crypto.Tox 11import Crypto.Tox
12import Control.Concurrent.STM 12import Control.Concurrent.STM
13import Network.Address 13import 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
220cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO Cookie 220createCookie :: TransportCrypto -> NodeInfo -> PublicKey -> IO Cookie
221cookieRequestH crypto ni (CookieRequest remoteUserKey) = do 221createCookie 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
236cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO Cookie
237cookieRequestH 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
240lanDiscoveryH :: Client -> NodeInfo -> NodeInfo -> IO (Maybe (Message -> Message)) 245lanDiscoveryH :: Client -> NodeInfo -> NodeInfo -> IO (Maybe (Message -> Message))
241lanDiscoveryH client _ ni = do 246lanDiscoveryH client _ ni = do
242 forkIO $ do 247 forkIO $ do