From 3a19d940e6ce56cfe9f46a13a3ae21bc4b2be338 Mon Sep 17 00:00:00 2001 From: James Crayne Date: Thu, 31 May 2018 17:18:32 +0000 Subject: canonicalize sockaddr before lookups and insertions into map --- src/Network/Tox/Crypto/Handlers.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs index 1aaee998..b7414095 100644 --- a/src/Network/Tox/Crypto/Handlers.hs +++ b/src/Network/Tox/Crypto/Handlers.hs @@ -613,7 +613,8 @@ createNetCryptoOutQueue sessions newsession theirSessionKey pktq ncMyPacketNonce -- | add this session to the lookup maps, overwrite if its already in them addSessionToMapIfNotThere :: NetCryptoSessions -> SockAddr -> NetCryptoSession -> STM () -addSessionToMapIfNotThere sessions addr netCryptoSession = do +addSessionToMapIfNotThere sessions addrRaw netCryptoSession = do + let addr = either id id $ either4or6 addrRaw let dmsg msg = trace msg (return ()) dmsg $ "addSessionToMapIfNotThere sockaddr = " ++ show addr ++ ", sessionid = " ++ show (ncSessionId netCryptoSession) let remotePublicKey = ncTheirPublicKey netCryptoSession @@ -788,7 +789,8 @@ toHandshakeParams (key,hs) } handshakeH :: NetCryptoSessions -> SockAddr -> Handshake Encrypted -> IO (Maybe a) -handshakeH sessions addr hshake@(Handshake (Cookie n24 ecookie) nonce24 encrypted) = do +handshakeH sessions addrRaw hshake@(Handshake (Cookie n24 ecookie) nonce24 encrypted) = do + let addr = either id id $ either4or6 addrRaw dput XNetCrypto ("RECIEVED HANDSHAKE from " ++ show addr) -- Handle Handshake Message let crypto = transportCrypto sessions :: TransportCrypto -- cgit v1.2.3