diff options
author | James Crayne <jim.crayne@gmail.com> | 2018-05-31 17:18:32 +0000 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2018-05-31 17:18:32 +0000 |
commit | 3a19d940e6ce56cfe9f46a13a3ae21bc4b2be338 (patch) | |
tree | d8b14c13bbbfbfb58281f7fa97ad18b4043b36f7 /src/Network/Tox/Crypto/Handlers.hs | |
parent | f4ef80c5f921ee7f659c3bd4b6c8162ae0b4ccb8 (diff) |
canonicalize sockaddr before lookups and insertions into map
Diffstat (limited to 'src/Network/Tox/Crypto/Handlers.hs')
-rw-r--r-- | src/Network/Tox/Crypto/Handlers.hs | 6 |
1 files 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 | |||
613 | 613 | ||
614 | -- | add this session to the lookup maps, overwrite if its already in them | 614 | -- | add this session to the lookup maps, overwrite if its already in them |
615 | addSessionToMapIfNotThere :: NetCryptoSessions -> SockAddr -> NetCryptoSession -> STM () | 615 | addSessionToMapIfNotThere :: NetCryptoSessions -> SockAddr -> NetCryptoSession -> STM () |
616 | addSessionToMapIfNotThere sessions addr netCryptoSession = do | 616 | addSessionToMapIfNotThere sessions addrRaw netCryptoSession = do |
617 | let addr = either id id $ either4or6 addrRaw | ||
617 | let dmsg msg = trace msg (return ()) | 618 | let dmsg msg = trace msg (return ()) |
618 | dmsg $ "addSessionToMapIfNotThere sockaddr = " ++ show addr ++ ", sessionid = " ++ show (ncSessionId netCryptoSession) | 619 | dmsg $ "addSessionToMapIfNotThere sockaddr = " ++ show addr ++ ", sessionid = " ++ show (ncSessionId netCryptoSession) |
619 | let remotePublicKey = ncTheirPublicKey netCryptoSession | 620 | let remotePublicKey = ncTheirPublicKey netCryptoSession |
@@ -788,7 +789,8 @@ toHandshakeParams (key,hs) | |||
788 | } | 789 | } |
789 | 790 | ||
790 | handshakeH :: NetCryptoSessions -> SockAddr -> Handshake Encrypted -> IO (Maybe a) | 791 | handshakeH :: NetCryptoSessions -> SockAddr -> Handshake Encrypted -> IO (Maybe a) |
791 | handshakeH sessions addr hshake@(Handshake (Cookie n24 ecookie) nonce24 encrypted) = do | 792 | handshakeH sessions addrRaw hshake@(Handshake (Cookie n24 ecookie) nonce24 encrypted) = do |
793 | let addr = either id id $ either4or6 addrRaw | ||
792 | dput XNetCrypto ("RECIEVED HANDSHAKE from " ++ show addr) | 794 | dput XNetCrypto ("RECIEVED HANDSHAKE from " ++ show addr) |
793 | -- Handle Handshake Message | 795 | -- Handle Handshake Message |
794 | let crypto = transportCrypto sessions :: TransportCrypto | 796 | let crypto = transportCrypto sessions :: TransportCrypto |