summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/PeerWire/Handshake.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/PeerWire/Handshake.hs')
-rw-r--r--src/Network/BitTorrent/PeerWire/Handshake.hs15
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 #-}
9module Network.BitTorrent.PeerWire.Handshake 14module 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
17import Control.Applicative 22import Control.Applicative
@@ -28,11 +33,6 @@ import Network.BitTorrent.PeerID
28import Network.BitTorrent.PeerWire.ClientInfo 33import 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--
36data Handshake = Handshake { 36data 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.
73ppHandshake :: Handshake -> String 74ppHandshake :: Handshake -> String
74ppHandshake hs = BC.unpack (hsProtocol hs) ++ " " 75ppHandshake hs = BC.unpack (hsProtocol hs) ++ " "
75 ++ ppClientInfo (clientInfo (hsPeerID hs)) 76 ++ ppClientInfo (clientInfo (hsPeerID hs))