diff options
author | joe <joe@jerkface.net> | 2018-05-31 00:56:14 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2018-05-31 00:56:14 -0400 |
commit | 9e91ad5c7d29c2e5702ca86c73f1f699e1c2714a (patch) | |
tree | c0813636efa272b008a70a970abcff45e554dbc6 /src/Network | |
parent | f6ac09e60cb38c181b44c6bf51a3d58bdd75e7bc (diff) |
parseNetCrypto should peel id byte before deserializing the rest of the message.
Diffstat (limited to 'src/Network')
-rw-r--r-- | src/Network/Tox/Crypto/Transport.hs | 4 | ||||
-rw-r--r-- | src/Network/Tox/DHT/Transport.hs | 1 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/Network/Tox/Crypto/Transport.hs b/src/Network/Tox/Crypto/Transport.hs index 141ef792..1444ffca 100644 --- a/src/Network/Tox/Crypto/Transport.hs +++ b/src/Network/Tox/Crypto/Transport.hs | |||
@@ -81,8 +81,8 @@ data NetCrypto | |||
81 | | NetCrypto (CryptoPacket Encrypted) | 81 | | NetCrypto (CryptoPacket Encrypted) |
82 | 82 | ||
83 | parseNetCrypto :: ByteString -> SockAddr -> Either String (NetCrypto, SockAddr) | 83 | parseNetCrypto :: ByteString -> SockAddr -> Either String (NetCrypto, SockAddr) |
84 | parseNetCrypto pkt@(B.uncons -> Just (0x1a,_)) saddr = left ("parseNetCrypto: "++) $ (,saddr) . NetHandshake <$> runGet get pkt | 84 | parseNetCrypto (B.uncons -> Just (0x1a,pkt)) saddr = left ("parseNetCrypto: "++) $ (,saddr) . NetHandshake <$> runGet get pkt |
85 | parseNetCrypto pkt@(B.uncons -> Just (0x1b,_)) saddr = left ("parseNetCrypto: "++) $ (,saddr) . NetCrypto <$> runGet get pkt | 85 | parseNetCrypto (B.uncons -> Just (0x1b,pkt)) saddr = left ("parseNetCrypto: "++) $ (,saddr) . NetCrypto <$> runGet get pkt |
86 | parseNetCrypto _ _ = Left "parseNetCrypto: ?" | 86 | parseNetCrypto _ _ = Left "parseNetCrypto: ?" |
87 | 87 | ||
88 | encodeNetCrypto :: NetCrypto -> SockAddr -> (ByteString, SockAddr) | 88 | encodeNetCrypto :: NetCrypto -> SockAddr -> (ByteString, SockAddr) |
diff --git a/src/Network/Tox/DHT/Transport.hs b/src/Network/Tox/DHT/Transport.hs index f7feea3b..59b22673 100644 --- a/src/Network/Tox/DHT/Transport.hs +++ b/src/Network/Tox/DHT/Transport.hs | |||
@@ -371,6 +371,7 @@ data CookieData = CookieData -- 16 (mac) | |||
371 | , longTermKey :: PublicKey -- 32 | 371 | , longTermKey :: PublicKey -- 32 |
372 | , dhtKey :: PublicKey -- + 32 | 372 | , dhtKey :: PublicKey -- + 32 |
373 | } -- = 88 bytes when encrypted. | 373 | } -- = 88 bytes when encrypted. |
374 | deriving Show | ||
374 | 375 | ||
375 | instance Sized CookieData where | 376 | instance Sized CookieData where |
376 | size = ConstSize 72 | 377 | size = ConstSize 72 |