summaryrefslogtreecommitdiff
path: root/src/Network/Tox/DHT/Handlers.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2018-06-02 04:08:54 -0400
committerjoe <joe@jerkface.net>2018-06-02 04:08:54 -0400
commitbc8c61dd7933f1cacd91282c0476f7bc46795daf (patch)
treea1a70df0fecd312152bc7ad421457dc28cf7e18e /src/Network/Tox/DHT/Handlers.hs
parent1a2e32e7ae1e6e2e9e02ae4fefeb3645e4fb6028 (diff)
Change Cookie -> Cookie Encrypted
Diffstat (limited to 'src/Network/Tox/DHT/Handlers.hs')
-rw-r--r--src/Network/Tox/DHT/Handlers.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Network/Tox/DHT/Handlers.hs b/src/Network/Tox/DHT/Handlers.hs
index af6eda8c..238fb0d0 100644
--- a/src/Network/Tox/DHT/Handlers.hs
+++ b/src/Network/Tox/DHT/Handlers.hs
@@ -92,7 +92,7 @@ instance Show PacketKind where
92 showsPrec d (PacketKind x) = mappend "PacketKind " . showsPrec (d+1) x 92 showsPrec d (PacketKind x) = mappend "PacketKind " . showsPrec (d+1) x
93 93
94msgType :: ( Serialize (f DHTRequest) 94msgType :: ( Serialize (f DHTRequest)
95 , Serialize (f Cookie), Serialize (f CookieRequest) 95 , Serialize (f (Cookie Encrypted)), Serialize (f CookieRequest)
96 , Serialize (f SendNodes), Serialize (f GetNodes) 96 , Serialize (f SendNodes), Serialize (f GetNodes)
97 , Serialize (f Pong), Serialize (f Ping) 97 , Serialize (f Pong), Serialize (f Ping)
98 ) => DHTMessage f -> PacketKind 98 ) => DHTMessage f -> PacketKind
@@ -218,7 +218,7 @@ getNodesH routing addr (GetNodes nid) = do
218 218
219 k = 4 219 k = 4
220 220
221createCookie :: TransportCrypto -> NodeInfo -> PublicKey -> IO Cookie 221createCookie :: TransportCrypto -> NodeInfo -> PublicKey -> IO (Cookie Encrypted)
222createCookie crypto ni remoteUserKey = do 222createCookie crypto ni remoteUserKey = do
223 (n24,sym) <- atomically $ do 223 (n24,sym) <- atomically $ do
224 n24 <- transportNewNonce crypto 224 n24 <- transportNewNonce crypto
@@ -234,7 +234,7 @@ createCookie crypto ni remoteUserKey = do
234 dput XNetCrypto $ "Created cookie with n24 = 0x" ++ show n24 ++ "\n sym=" ++ show sym 234 dput XNetCrypto $ "Created cookie with n24 = 0x" ++ show n24 ++ "\n sym=" ++ show sym
235 return $ Cookie n24 edta 235 return $ Cookie n24 edta
236 236
237cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO Cookie 237cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO (Cookie Encrypted)
238cookieRequestH crypto ni (CookieRequest remoteUserKey) = do 238cookieRequestH crypto ni (CookieRequest remoteUserKey) = do
239 dput XNetCrypto $ unlines 239 dput XNetCrypto $ unlines
240 [ "CookieRequest! remoteUserKey=" ++ show (key2id remoteUserKey) 240 [ "CookieRequest! remoteUserKey=" ++ show (key2id remoteUserKey)
@@ -311,7 +311,7 @@ loseCookieKey var saddr pk = do
311 _ -> return () -- unreachable? 311 _ -> return () -- unreachable?
312 312
313 313
314cookieRequest :: TransportCrypto -> Client -> PublicKey -> NodeInfo -> IO (Maybe Cookie) 314cookieRequest :: TransportCrypto -> Client -> PublicKey -> NodeInfo -> IO (Maybe (Cookie Encrypted))
315cookieRequest crypto client localUserKey addr = do 315cookieRequest crypto client localUserKey addr = do
316 let sockAddr = nodeAddr addr 316 let sockAddr = nodeAddr addr
317 nid = id2key $ nodeId addr 317 nid = id2key $ nodeId addr
@@ -330,7 +330,7 @@ cookieRequest crypto client localUserKey addr = do
330 dput XNetCrypto $ show addr ++ " -cookieResponse-> " ++ show reply 330 dput XNetCrypto $ show addr ++ " -cookieResponse-> " ++ show reply
331 return $ join reply 331 return $ join reply
332 332
333unCookie :: DHTMessage t -> Maybe (t Cookie) 333unCookie :: DHTMessage t -> Maybe (t (Cookie Encrypted))
334unCookie (DHTCookie n24 fcookie) = Just fcookie 334unCookie (DHTCookie n24 fcookie) = Just fcookie
335unCookie _ = Nothing 335unCookie _ = Nothing
336 336
@@ -416,7 +416,7 @@ isCookieRequest :: (f CookieRequest -> CookieRequest) -> DHTMessage f -> Either
416isCookieRequest unpack (DHTCookieRequest a) = Right $ unpack $ asymmData a 416isCookieRequest unpack (DHTCookieRequest a) = Right $ unpack $ asymmData a
417isCookieRequest _ _ = Left "Bad cookie request" 417isCookieRequest _ _ = Left "Bad cookie request"
418 418
419mkCookie :: TransactionId -> NodeInfo -> NodeInfo -> Cookie -> DHTMessage ((,) Nonce8) 419mkCookie :: TransactionId -> NodeInfo -> NodeInfo -> Cookie Encrypted -> DHTMessage ((,) Nonce8)
420mkCookie (TransactionId n8 n24) src dst cookie = DHTCookie n24 (n8,cookie) 420mkCookie (TransactionId n8 n24) src dst cookie = DHTCookie n24 (n8,cookie)
421 421
422isDHTRequest :: (f DHTRequest -> DHTRequest) -> DHTMessage f -> Either String DHTRequest 422isDHTRequest :: (f DHTRequest -> DHTRequest) -> DHTMessage f -> Either String DHTRequest