diff options
author | jim@bo <jim@bo> | 2018-06-22 15:06:51 -0400 |
---|---|---|
committer | jim@bo <jim@bo> | 2018-06-22 15:06:51 -0400 |
commit | d96aa110fcc32d9a8afb14564f45f296dd1624e4 (patch) | |
tree | 8043a7ae3623501c012198fb4dd2f1eaf9c79b61 /src/Network/Tox/Crypto/Transport.hs | |
parent | 2f0e7ebc7bc3abf5cb03ccff2de77d3557ba2702 (diff) |
packet request off by 1 serializatoin fix & getMissing fix
Diffstat (limited to 'src/Network/Tox/Crypto/Transport.hs')
-rw-r--r-- | src/Network/Tox/Crypto/Transport.hs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Network/Tox/Crypto/Transport.hs b/src/Network/Tox/Crypto/Transport.hs index 678bb16d..ea8565b2 100644 --- a/src/Network/Tox/Crypto/Transport.hs +++ b/src/Network/Tox/Crypto/Transport.hs | |||
@@ -4,6 +4,7 @@ | |||
4 | {-# LANGUAGE FlexibleInstances #-} | 4 | {-# LANGUAGE FlexibleInstances #-} |
5 | {-# LANGUAGE LambdaCase #-} | 5 | {-# LANGUAGE LambdaCase #-} |
6 | {-# LANGUAGE TupleSections #-} | 6 | {-# LANGUAGE TupleSections #-} |
7 | {-# LANGUAGE StandaloneDeriving #-} | ||
7 | module Network.Tox.Crypto.Transport | 8 | module Network.Tox.Crypto.Transport |
8 | ( parseCrypto | 9 | ( parseCrypto |
9 | , encodeCrypto | 10 | , encodeCrypto |
@@ -97,7 +98,7 @@ encodeHandshakes x saddr = (B.cons 0x1a (runPut $ put x),saddr) | |||
97 | createRequestPacket :: Word32 -> [Word32] -> CryptoMessage | 98 | createRequestPacket :: Word32 -> [Word32] -> CryptoMessage |
98 | createRequestPacket seqno xs = UpToN PacketRequest (B.pack ns) | 99 | createRequestPacket seqno xs = UpToN PacketRequest (B.pack ns) |
99 | where | 100 | where |
100 | ys = Prelude.map (subtract seqno) xs | 101 | ys = Prelude.map (subtract (seqno - 1)) xs |
101 | reduceToSums [] = [] | 102 | reduceToSums [] = [] |
102 | reduceToSums (x:xs) = x:(reduceToSums $ Prelude.map (subtract x) xs) | 103 | reduceToSums (x:xs) = x:(reduceToSums $ Prelude.map (subtract x) xs) |
103 | makeZeroes :: Word32 -> [Word32] | 104 | makeZeroes :: Word32 -> [Word32] |
@@ -168,6 +169,8 @@ data CryptoPacket (f :: * -> *) = CryptoPacket | |||
168 | , pktData :: f CryptoData | 169 | , pktData :: f CryptoData |
169 | } | 170 | } |
170 | 171 | ||
172 | deriving instance Show (CryptoPacket Encrypted) | ||
173 | |||
171 | instance Sized CryptoData where | 174 | instance Sized CryptoData where |
172 | size = contramap bufferStart size | 175 | size = contramap bufferStart size |
173 | <> contramap bufferEnd size | 176 | <> contramap bufferEnd size |