diff options
author | Sam T <sta.cs.vsu@gmail.com> | 2013-04-07 05:36:37 +0400 |
---|---|---|
committer | Sam T <sta.cs.vsu@gmail.com> | 2013-04-07 05:36:37 +0400 |
commit | e333666cc7c4de24ec10b948afeeb3bfe1976ba1 (patch) | |
tree | 3f1a163939e6052ac18f9eb838d62d60bb53db00 /src/Network/Torrent/Handshake.hs | |
parent | faa63b25305c94e22706a639e62d47115dd70983 (diff) |
~ fix goddamn length encoding bug
Diffstat (limited to 'src/Network/Torrent/Handshake.hs')
-rw-r--r-- | src/Network/Torrent/Handshake.hs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/Network/Torrent/Handshake.hs b/src/Network/Torrent/Handshake.hs index b17afaf7..c14fd591 100644 --- a/src/Network/Torrent/Handshake.hs +++ b/src/Network/Torrent/Handshake.hs | |||
@@ -26,7 +26,7 @@ data Handshake = Handshake { | |||
26 | 26 | ||
27 | instance Serialize Handshake where | 27 | instance Serialize Handshake where |
28 | put hs = do | 28 | put hs = do |
29 | putWord8 (49 + fromIntegral (B.length (hsProtocol hs))) | 29 | putWord8 (fromIntegral (B.length (hsProtocol hs))) |
30 | putByteString (hsProtocol hs) | 30 | putByteString (hsProtocol hs) |
31 | putWord64be (hsReserved hs) | 31 | putWord64be (hsReserved hs) |
32 | putByteString (hsInfoHash hs) | 32 | putByteString (hsInfoHash hs) |
@@ -34,7 +34,7 @@ instance Serialize Handshake where | |||
34 | 34 | ||
35 | get = do | 35 | get = do |
36 | len <- getWord8 | 36 | len <- getWord8 |
37 | Handshake <$> getBytes (fromIntegral (len - 49)) | 37 | Handshake <$> getBytes (fromIntegral len) |
38 | <*> getWord64be | 38 | <*> getWord64be |
39 | <*> getBytes 20 | 39 | <*> getBytes 20 |
40 | <*> get | 40 | <*> get |