diff options
author | James Crayne <jim.crayne@gmail.com> | 2018-05-29 00:54:28 +0000 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2018-05-29 00:54:28 +0000 |
commit | f2e7d76a22681beabcfdbc727b3fe320d34af7e5 (patch) | |
tree | 8a7e26847d8550c42cc70dbffbbcf66c16c58b15 /src/Network/Tox/DHT | |
parent | 8980cc601aad0851e7a3f0ddcf55f1ad3fe6963d (diff) |
netCrypto function, ready for testing?
Diffstat (limited to 'src/Network/Tox/DHT')
-rw-r--r-- | src/Network/Tox/DHT/Handlers.hs | 17 |
1 files changed, 11 insertions, 6 deletions
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 |