diff options
Diffstat (limited to 'src/Network/Torrent/PeerWire')
-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 |