diff options
author | Joe Crayne <joe@jerkface.net> | 2018-12-02 16:36:03 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2018-12-16 14:08:26 -0500 |
commit | 93e51f29cc6c25455a5f91dbc1c3e678922523fd (patch) | |
tree | d9911cdc48cf4de510fcfc5693def6cb9d1b6e81 /src/Network/Tox | |
parent | e64a0efd2ca29257c189343b6dc75f6bee29d66d (diff) |
TCP cache: Use (Down POSIXTime) for MinMax priority.
Diffstat (limited to 'src/Network/Tox')
-rw-r--r-- | src/Network/Tox/TCP.hs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/Network/Tox/TCP.hs b/src/Network/Tox/TCP.hs index 0780f121..28bcd244 100644 --- a/src/Network/Tox/TCP.hs +++ b/src/Network/Tox/TCP.hs | |||
@@ -8,10 +8,9 @@ import Control.Concurrent | |||
8 | import Control.Concurrent.STM | 8 | import Control.Concurrent.STM |
9 | import Data.Functor.Identity | 9 | import Data.Functor.Identity |
10 | import Data.Serialize | 10 | import Data.Serialize |
11 | import System.IO (Handle) | ||
12 | 11 | ||
13 | import Crypto.Tox | 12 | import Crypto.Tox |
14 | import Data.ByteString (hPut,hGet,ByteString) | 13 | import Data.ByteString (hPut,hGet) |
15 | import Data.Tox.Relay | 14 | import Data.Tox.Relay |
16 | import Network.Address (setPort,PortNumber,SockAddr) | 15 | import Network.Address (setPort,PortNumber,SockAddr) |
17 | import Network.QueryResponse | 16 | import Network.QueryResponse |
@@ -60,8 +59,8 @@ tcpStream crypto = StreamHandshake | |||
60 | nread <- newMVar (sessionBaseNonce $ runIdentity $ welcomeData welcome) | 59 | nread <- newMVar (sessionBaseNonce $ runIdentity $ welcomeData welcome) |
61 | let them = sessionPublicKey $ runIdentity $ welcomeData welcome | 60 | let them = sessionPublicKey $ runIdentity $ welcomeData welcome |
62 | return SessionProtocol | 61 | return SessionProtocol |
63 | { streamGoodbye = \h -> return () -- No goodbye packet? Seems rude. | 62 | { streamGoodbye = return () -- No goodbye packet? Seems rude. |
64 | , streamDecode = \h -> do | 63 | , streamDecode = do |
65 | decode <$> hGet h 2 >>= \case | 64 | decode <$> hGet h 2 >>= \case |
66 | Left _ -> return Nothing | 65 | Left _ -> return Nothing |
67 | Right len -> do | 66 | Right len -> do |
@@ -74,9 +73,8 @@ tcpStream crypto = StreamHandshake | |||
74 | return $ either (const Nothing) Just r | 73 | return $ either (const Nothing) Just r |
75 | , streamEncode = \y -> do | 74 | , streamEncode = \y -> do |
76 | n24 <- takeMVar nsend | 75 | n24 <- takeMVar nsend |
77 | let bs = encode $ encrypt (noncef' n24) $ encodePlain y | 76 | hPut h $ encode $ encrypt (noncef' n24) $ encodePlain y |
78 | putMVar nsend (incrementNonce24 n24) | 77 | putMVar nsend (incrementNonce24 n24) |
79 | return bs -- XXX: Should we wait until this bytestring is sent before putting the nonce back in the MVar? | ||
80 | } | 78 | } |
81 | , streamAddr = nodeAddr | 79 | , streamAddr = nodeAddr |
82 | } | 80 | } |