summaryrefslogtreecommitdiff
path: root/src/Network/Tox
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2018-12-02 16:36:03 -0500
committerJoe Crayne <joe@jerkface.net>2018-12-16 14:08:26 -0500
commit93e51f29cc6c25455a5f91dbc1c3e678922523fd (patch)
treed9911cdc48cf4de510fcfc5693def6cb9d1b6e81 /src/Network/Tox
parente64a0efd2ca29257c189343b6dc75f6bee29d66d (diff)
TCP cache: Use (Down POSIXTime) for MinMax priority.
Diffstat (limited to 'src/Network/Tox')
-rw-r--r--src/Network/Tox/TCP.hs10
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
8import Control.Concurrent.STM 8import Control.Concurrent.STM
9import Data.Functor.Identity 9import Data.Functor.Identity
10import Data.Serialize 10import Data.Serialize
11import System.IO (Handle)
12 11
13import Crypto.Tox 12import Crypto.Tox
14import Data.ByteString (hPut,hGet,ByteString) 13import Data.ByteString (hPut,hGet)
15import Data.Tox.Relay 14import Data.Tox.Relay
16import Network.Address (setPort,PortNumber,SockAddr) 15import Network.Address (setPort,PortNumber,SockAddr)
17import Network.QueryResponse 16import 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 }