diff options
Diffstat (limited to 'src/Network/Tox/DHT')
-rw-r--r-- | src/Network/Tox/DHT/Handlers.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Network/Tox/DHT/Handlers.hs b/src/Network/Tox/DHT/Handlers.hs index 238fb0d0..dd586430 100644 --- a/src/Network/Tox/DHT/Handlers.hs +++ b/src/Network/Tox/DHT/Handlers.hs | |||
@@ -5,6 +5,7 @@ | |||
5 | {-# LANGUAGE TupleSections #-} | 5 | {-# LANGUAGE TupleSections #-} |
6 | module Network.Tox.DHT.Handlers where | 6 | module Network.Tox.DHT.Handlers where |
7 | 7 | ||
8 | import Debug.Trace | ||
8 | import Network.Tox.DHT.Transport as DHTTransport | 9 | import Network.Tox.DHT.Transport as DHTTransport |
9 | import Network.QueryResponse as QR hiding (Client) | 10 | import Network.QueryResponse as QR hiding (Client) |
10 | import qualified Network.QueryResponse as QR (Client) | 11 | import qualified Network.QueryResponse as QR (Client) |
@@ -234,6 +235,23 @@ createCookie crypto ni remoteUserKey = do | |||
234 | dput XNetCrypto $ "Created cookie with n24 = 0x" ++ show n24 ++ "\n sym=" ++ show sym | 235 | dput XNetCrypto $ "Created cookie with n24 = 0x" ++ show n24 ++ "\n sym=" ++ show sym |
235 | return $ Cookie n24 edta | 236 | return $ Cookie n24 edta |
236 | 237 | ||
238 | createCookieSTM :: POSIXTime -> TransportCrypto -> NodeInfo -> PublicKey -> STM (Cookie Encrypted) | ||
239 | createCookieSTM now crypto ni remoteUserKey = do | ||
240 | let dmsg msg = trace msg (return ()) | ||
241 | (n24,sym) <- do | ||
242 | n24 <- transportNewNonce crypto | ||
243 | sym <- transportSymmetric crypto | ||
244 | return (n24,sym) | ||
245 | let timestamp = round (now * 1000000) | ||
246 | let dta = encodePlain $ CookieData | ||
247 | { cookieTime = timestamp | ||
248 | , longTermKey = remoteUserKey | ||
249 | , dhtKey = transportPublic crypto | ||
250 | } | ||
251 | edta = encryptSymmetric sym n24 dta | ||
252 | dmsg $ "(createCookieSTM) Created cookie with n24 = 0x" ++ show n24 ++ "\n sym=" ++ show sym | ||
253 | return $ Cookie n24 edta | ||
254 | |||
237 | cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO (Cookie Encrypted) | 255 | cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO (Cookie Encrypted) |
238 | cookieRequestH crypto ni (CookieRequest remoteUserKey) = do | 256 | cookieRequestH crypto ni (CookieRequest remoteUserKey) = do |
239 | dput XNetCrypto $ unlines | 257 | dput XNetCrypto $ unlines |