summaryrefslogtreecommitdiff
path: root/src/Network/Tox/Crypto
diff options
context:
space:
mode:
authorjim@bo <jim@bo>2018-06-22 15:06:51 -0400
committerjim@bo <jim@bo>2018-06-22 15:06:51 -0400
commitd96aa110fcc32d9a8afb14564f45f296dd1624e4 (patch)
tree8043a7ae3623501c012198fb4dd2f1eaf9c79b61 /src/Network/Tox/Crypto
parent2f0e7ebc7bc3abf5cb03ccff2de77d3557ba2702 (diff)
packet request off by 1 serializatoin fix & getMissing fix
Diffstat (limited to 'src/Network/Tox/Crypto')
-rw-r--r--src/Network/Tox/Crypto/Transport.hs5
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 #-}
7module Network.Tox.Crypto.Transport 8module 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)
97createRequestPacket :: Word32 -> [Word32] -> CryptoMessage 98createRequestPacket :: Word32 -> [Word32] -> CryptoMessage
98createRequestPacket seqno xs = UpToN PacketRequest (B.pack ns) 99createRequestPacket 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
172deriving instance Show (CryptoPacket Encrypted)
173
171instance Sized CryptoData where 174instance Sized CryptoData where
172 size = contramap bufferStart size 175 size = contramap bufferStart size
173 <> contramap bufferEnd size 176 <> contramap bufferEnd size