diff options
Diffstat (limited to 'src/Network/Tox/DHT/Handlers.hs')
-rw-r--r-- | src/Network/Tox/DHT/Handlers.hs | 12 |
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 | ||
94 | msgType :: ( Serialize (f DHTRequest) | 94 | msgType :: ( 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 | ||
221 | createCookie :: TransportCrypto -> NodeInfo -> PublicKey -> IO Cookie | 221 | createCookie :: TransportCrypto -> NodeInfo -> PublicKey -> IO (Cookie Encrypted) |
222 | createCookie crypto ni remoteUserKey = do | 222 | createCookie 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 | ||
237 | cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO Cookie | 237 | cookieRequestH :: TransportCrypto -> NodeInfo -> CookieRequest -> IO (Cookie Encrypted) |
238 | cookieRequestH crypto ni (CookieRequest remoteUserKey) = do | 238 | cookieRequestH 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 | ||
314 | cookieRequest :: TransportCrypto -> Client -> PublicKey -> NodeInfo -> IO (Maybe Cookie) | 314 | cookieRequest :: TransportCrypto -> Client -> PublicKey -> NodeInfo -> IO (Maybe (Cookie Encrypted)) |
315 | cookieRequest crypto client localUserKey addr = do | 315 | cookieRequest 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 | ||
333 | unCookie :: DHTMessage t -> Maybe (t Cookie) | 333 | unCookie :: DHTMessage t -> Maybe (t (Cookie Encrypted)) |
334 | unCookie (DHTCookie n24 fcookie) = Just fcookie | 334 | unCookie (DHTCookie n24 fcookie) = Just fcookie |
335 | unCookie _ = Nothing | 335 | unCookie _ = Nothing |
336 | 336 | ||
@@ -416,7 +416,7 @@ isCookieRequest :: (f CookieRequest -> CookieRequest) -> DHTMessage f -> Either | |||
416 | isCookieRequest unpack (DHTCookieRequest a) = Right $ unpack $ asymmData a | 416 | isCookieRequest unpack (DHTCookieRequest a) = Right $ unpack $ asymmData a |
417 | isCookieRequest _ _ = Left "Bad cookie request" | 417 | isCookieRequest _ _ = Left "Bad cookie request" |
418 | 418 | ||
419 | mkCookie :: TransactionId -> NodeInfo -> NodeInfo -> Cookie -> DHTMessage ((,) Nonce8) | 419 | mkCookie :: TransactionId -> NodeInfo -> NodeInfo -> Cookie Encrypted -> DHTMessage ((,) Nonce8) |
420 | mkCookie (TransactionId n8 n24) src dst cookie = DHTCookie n24 (n8,cookie) | 420 | mkCookie (TransactionId n8 n24) src dst cookie = DHTCookie n24 (n8,cookie) |
421 | 421 | ||
422 | isDHTRequest :: (f DHTRequest -> DHTRequest) -> DHTMessage f -> Either String DHTRequest | 422 | isDHTRequest :: (f DHTRequest -> DHTRequest) -> DHTMessage f -> Either String DHTRequest |