summaryrefslogtreecommitdiff
path: root/src/Network/Tox/Crypto/Transport.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/Tox/Crypto/Transport.hs')
-rw-r--r--src/Network/Tox/Crypto/Transport.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Network/Tox/Crypto/Transport.hs b/src/Network/Tox/Crypto/Transport.hs
index ce3bafee..fab0f3e2 100644
--- a/src/Network/Tox/Crypto/Transport.hs
+++ b/src/Network/Tox/Crypto/Transport.hs
@@ -7,6 +7,7 @@
7module Network.Tox.Crypto.Transport 7module Network.Tox.Crypto.Transport
8 ( parseCrypto 8 ( parseCrypto
9 , encodeCrypto 9 , encodeCrypto
10 , unpadCryptoMsg
10 , parseHandshakes 11 , parseHandshakes
11 , encodeHandshakes 12 , encodeHandshakes
12 , CryptoData(..) 13 , CryptoData(..)
@@ -220,6 +221,17 @@ data UserStatus = Online | Away | Busy deriving (Show,Read,Eq,Ord,Enum)
220 221
221data TypingStatus = NotTyping | Typing deriving (Show,Read,Eq,Ord,Enum) 222data TypingStatus = NotTyping | Typing deriving (Show,Read,Eq,Ord,Enum)
222 223
224unpadCryptoMsg :: CryptoMessage -> CryptoMessage
225unpadCryptoMsg x@(TwoByte Padding (toEnum8 -> mid))
226 | msgSizeParam mid == Just (True,0) = OneByte mid
227unpadCryptoMsg x@(UpToN mid0 (B.dropWhile (==0) -> B.uncons -> Just (toEnum8 -> mid,bytes)))
228 | mid0 == Padding
229 = case msgSizeParam mid of
230 Just (True,0) -> OneByte mid
231 Just (True,1) -> TwoByte mid (B.head bytes)
232 _ -> UpToN mid bytes
233unpadCryptoMsg x = x
234
223data CryptoMessage 235data CryptoMessage
224 = OneByte { msgID :: MessageID } 236 = OneByte { msgID :: MessageID }
225 | TwoByte { msgID :: MessageID, msgByte :: Word8 } 237 | TwoByte { msgID :: MessageID, msgByte :: Word8 }