summaryrefslogtreecommitdiff
path: root/src/Network/Tox/Crypto/Handlers.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2018-06-01 23:53:35 -0400
committerjoe <joe@jerkface.net>2018-06-01 23:53:35 -0400
commit05e750fef5cdf54ffa9e28f2a40286efcaa988a0 (patch)
treeb84d72d07fff24318ee3011e37da969ca869f0df /src/Network/Tox/Crypto/Handlers.hs
parent8749f7cd8a0811d3a5730a74221d069d20354946 (diff)
Separate functions for cryptoNetHandler cases.
Diffstat (limited to 'src/Network/Tox/Crypto/Handlers.hs')
-rw-r--r--src/Network/Tox/Crypto/Handlers.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs
index dcae9f2f..bde286fe 100644
--- a/src/Network/Tox/Crypto/Handlers.hs
+++ b/src/Network/Tox/Crypto/Handlers.hs
@@ -669,9 +669,12 @@ updateCryptoSession sessions addr hp session = do
669 then freshCryptoSession sessions addr hp -- basenonce mismatch, trigger refresh 669 then freshCryptoSession sessions addr hp -- basenonce mismatch, trigger refresh
670 else atomically $ writeTVar (ncState session) {-Accepted-}(InProgress AwaitingSessionPacket) 670 else atomically $ writeTVar (ncState session) {-Accepted-}(InProgress AwaitingSessionPacket)
671 671
672
673cryptoNetHandler :: NetCryptoSessions -> SockAddr -> NetCrypto -> IO (Maybe (NetCrypto -> NetCrypto)) 672cryptoNetHandler :: NetCryptoSessions -> SockAddr -> NetCrypto -> IO (Maybe (NetCrypto -> NetCrypto))
674cryptoNetHandler sessions addr (NetHandshake (Handshake (Cookie n24 ecookie) nonce24 encrypted)) = do 673cryptoNetHandler sessions addr (NetHandshake hs) = handshakeH sessions addr hs
674cryptoNetHandler sessions addr (NetCrypto pkt) = sessionPacketH sessions addr pkt
675
676handshakeH :: NetCryptoSessions -> SockAddr -> Handshake Encrypted -> IO (Maybe a)
677handshakeH sessions addr (Handshake (Cookie n24 ecookie) nonce24 encrypted) = do
675 dput XNetCrypto ("RECIEVED HANDSHAKE from " ++ show addr) 678 dput XNetCrypto ("RECIEVED HANDSHAKE from " ++ show addr)
676 -- Handle Handshake Message 679 -- Handle Handshake Message
677 let crypto = transportCrypto sessions 680 let crypto = transportCrypto sessions
@@ -746,7 +749,8 @@ cryptoNetHandler sessions addr (NetHandshake (Handshake (Cookie n24 ecookie) non
746 updateCryptoSession sessions addr hp session -- update existing session 749 updateCryptoSession sessions addr hp session -- update existing session
747 return Nothing 750 return Nothing
748 751
749cryptoNetHandler sessions addr (NetCrypto (CryptoPacket nonce16 encrypted)) = do 752sessionPacketH :: NetCryptoSessions -> SockAddr -> CryptoPacket Encrypted -> IO (Maybe (x -> x))
753sessionPacketH sessions addr (CryptoPacket nonce16 encrypted) = do
750 dput XNetCrypto ("RECIEVED CRYPTOPACKET from " ++ show addr) 754 dput XNetCrypto ("RECIEVED CRYPTOPACKET from " ++ show addr)
751 let crypto = transportCrypto sessions 755 let crypto = transportCrypto sessions
752 allsessions = netCryptoSessions sessions 756 allsessions = netCryptoSessions sessions