diff options
Diffstat (limited to 'src/Network/BitTorrent/PeerWire/Handshake.hs')
-rw-r--r-- | src/Network/BitTorrent/PeerWire/Handshake.hs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/Network/BitTorrent/PeerWire/Handshake.hs b/src/Network/BitTorrent/PeerWire/Handshake.hs index 7a250782..3fdb48be 100644 --- a/src/Network/BitTorrent/PeerWire/Handshake.hs +++ b/src/Network/BitTorrent/PeerWire/Handshake.hs | |||
@@ -5,13 +5,18 @@ | |||
5 | -- Stability : experimental | 5 | -- Stability : experimental |
6 | -- Portability : portable | 6 | -- Portability : portable |
7 | -- | 7 | -- |
8 | -- In order to establish the connection between peers we should send | ||
9 | -- 'Handshake' message. The 'Handshake' is a required message and | ||
10 | -- must be the first message transmitted by the peer to the another | ||
11 | -- peer. | ||
12 | -- | ||
8 | {-# LANGUAGE OverloadedStrings #-} | 13 | {-# LANGUAGE OverloadedStrings #-} |
9 | module Network.BitTorrent.PeerWire.Handshake | 14 | module Network.BitTorrent.PeerWire.Handshake |
10 | ( Handshake | 15 | ( Handshake |
11 | , handshakeMaxSize | ||
12 | , defaultBTProtocol, defaultReserved, defaultHandshake | ||
13 | , handshake | 16 | , handshake |
14 | , ppHandshake | 17 | , ppHandshake |
18 | , defaultHandshake, defaultBTProtocol, defaultReserved | ||
19 | , handshakeMaxSize | ||
15 | ) where | 20 | ) where |
16 | 21 | ||
17 | import Control.Applicative | 22 | import Control.Applicative |
@@ -28,11 +33,6 @@ import Network.BitTorrent.PeerID | |||
28 | import Network.BitTorrent.PeerWire.ClientInfo | 33 | import Network.BitTorrent.PeerWire.ClientInfo |
29 | 34 | ||
30 | 35 | ||
31 | -- | In order to establish the connection between peers we should send | ||
32 | -- 'Handshake' message. The 'Handshake' is a required message and | ||
33 | -- must be the first message transmitted by the peer to the another | ||
34 | -- peer. | ||
35 | -- | ||
36 | data Handshake = Handshake { | 36 | data Handshake = Handshake { |
37 | -- | Identifier of the protocol. | 37 | -- | Identifier of the protocol. |
38 | hsProtocol :: ByteString | 38 | hsProtocol :: ByteString |
@@ -70,6 +70,7 @@ instance Serialize Handshake where | |||
70 | <*> get | 70 | <*> get |
71 | 71 | ||
72 | -- TODO add reserved bits info | 72 | -- TODO add reserved bits info |
73 | -- | Format handshake in human readable form. | ||
73 | ppHandshake :: Handshake -> String | 74 | ppHandshake :: Handshake -> String |
74 | ppHandshake hs = BC.unpack (hsProtocol hs) ++ " " | 75 | ppHandshake hs = BC.unpack (hsProtocol hs) ++ " " |
75 | ++ ppClientInfo (clientInfo (hsPeerID hs)) | 76 | ++ ppClientInfo (clientInfo (hsPeerID hs)) |