summaryrefslogtreecommitdiff
path: root/src/Network
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2018-05-31 00:56:14 -0400
committerjoe <joe@jerkface.net>2018-05-31 00:56:14 -0400
commit9e91ad5c7d29c2e5702ca86c73f1f699e1c2714a (patch)
treec0813636efa272b008a70a970abcff45e554dbc6 /src/Network
parentf6ac09e60cb38c181b44c6bf51a3d58bdd75e7bc (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.hs4
-rw-r--r--src/Network/Tox/DHT/Transport.hs1
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
83parseNetCrypto :: ByteString -> SockAddr -> Either String (NetCrypto, SockAddr) 83parseNetCrypto :: ByteString -> SockAddr -> Either String (NetCrypto, SockAddr)
84parseNetCrypto pkt@(B.uncons -> Just (0x1a,_)) saddr = left ("parseNetCrypto: "++) $ (,saddr) . NetHandshake <$> runGet get pkt 84parseNetCrypto (B.uncons -> Just (0x1a,pkt)) saddr = left ("parseNetCrypto: "++) $ (,saddr) . NetHandshake <$> runGet get pkt
85parseNetCrypto pkt@(B.uncons -> Just (0x1b,_)) saddr = left ("parseNetCrypto: "++) $ (,saddr) . NetCrypto <$> runGet get pkt 85parseNetCrypto (B.uncons -> Just (0x1b,pkt)) saddr = left ("parseNetCrypto: "++) $ (,saddr) . NetCrypto <$> runGet get pkt
86parseNetCrypto _ _ = Left "parseNetCrypto: ?" 86parseNetCrypto _ _ = Left "parseNetCrypto: ?"
87 87
88encodeNetCrypto :: NetCrypto -> SockAddr -> (ByteString, SockAddr) 88encodeNetCrypto :: 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
375instance Sized CookieData where 376instance Sized CookieData where
376 size = ConstSize 72 377 size = ConstSize 72