diff options
author | Sam T <sta.cs.vsu@gmail.com> | 2013-04-09 00:06:08 +0400 |
---|---|---|
committer | Sam T <sta.cs.vsu@gmail.com> | 2013-04-09 00:06:08 +0400 |
commit | 191a863e0cea911a8f44f25a67b31363461db42a (patch) | |
tree | cb0bd735214ece711e0e6f0a8aae4f8bf1a6d029 /src/Network/Torrent/PeerWire/Handshake.hs | |
parent | e0517ca99cfacffd9a045bdb475de4561d597fb2 (diff) |
+ handshake message max size
Diffstat (limited to 'src/Network/Torrent/PeerWire/Handshake.hs')
-rw-r--r-- | src/Network/Torrent/PeerWire/Handshake.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Network/Torrent/PeerWire/Handshake.hs b/src/Network/Torrent/PeerWire/Handshake.hs index ab255c14..ae65933f 100644 --- a/src/Network/Torrent/PeerWire/Handshake.hs +++ b/src/Network/Torrent/PeerWire/Handshake.hs | |||
@@ -1,6 +1,7 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | 1 | {-# LANGUAGE OverloadedStrings #-} |
2 | module Network.Torrent.PeerWire.Handshake | 2 | module Network.Torrent.PeerWire.Handshake |
3 | ( Handshake | 3 | ( Handshake |
4 | , handshakeMaxSize | ||
4 | , defaultProtocol, defaultReserved, defaultHandshake | 5 | , defaultProtocol, defaultReserved, defaultHandshake |
5 | ) where | 6 | ) where |
6 | 7 | ||
@@ -39,6 +40,10 @@ instance Serialize Handshake where | |||
39 | <*> get | 40 | <*> get |
40 | <*> get | 41 | <*> get |
41 | 42 | ||
43 | -- | Maximum size of handshake message in bytes. | ||
44 | handshakeMaxSize :: Int | ||
45 | handshakeMaxSize = 1 + 256 + 8 + 20 + 20 | ||
46 | |||
42 | -- | Default protocol string "BitTorrent protocol" as is. | 47 | -- | Default protocol string "BitTorrent protocol" as is. |
43 | defaultProtocol :: ByteString | 48 | defaultProtocol :: ByteString |
44 | defaultProtocol = "BitTorrent protocol" | 49 | defaultProtocol = "BitTorrent protocol" |
@@ -49,4 +54,4 @@ defaultReserved = 0 | |||
49 | 54 | ||
50 | -- | Length of info hash and peer id is unchecked, so it /should/ be equal 20. | 55 | -- | Length of info hash and peer id is unchecked, so it /should/ be equal 20. |
51 | defaultHandshake :: InfoHash -> PeerID -> Handshake | 56 | defaultHandshake :: InfoHash -> PeerID -> Handshake |
52 | defaultHandshake hash pid = Handshake defaultProtocol defaultReserved hash pid \ No newline at end of file | 57 | defaultHandshake = Handshake defaultProtocol defaultReserved \ No newline at end of file |