diff options
Diffstat (limited to 'src/Network/Tox/Crypto/Transport.hs')
-rw-r--r-- | src/Network/Tox/Crypto/Transport.hs | 12 |
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 @@ | |||
7 | module Network.Tox.Crypto.Transport | 7 | module 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 | ||
221 | data TypingStatus = NotTyping | Typing deriving (Show,Read,Eq,Ord,Enum) | 222 | data TypingStatus = NotTyping | Typing deriving (Show,Read,Eq,Ord,Enum) |
222 | 223 | ||
224 | unpadCryptoMsg :: CryptoMessage -> CryptoMessage | ||
225 | unpadCryptoMsg x@(TwoByte Padding (toEnum8 -> mid)) | ||
226 | | msgSizeParam mid == Just (True,0) = OneByte mid | ||
227 | unpadCryptoMsg 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 | ||
233 | unpadCryptoMsg x = x | ||
234 | |||
223 | data CryptoMessage | 235 | data CryptoMessage |
224 | = OneByte { msgID :: MessageID } | 236 | = OneByte { msgID :: MessageID } |
225 | | TwoByte { msgID :: MessageID, msgByte :: Word8 } | 237 | | TwoByte { msgID :: MessageID, msgByte :: Word8 } |