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.hs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Network/BitTorrent/PeerWire/Handshake.hs b/src/Network/BitTorrent/PeerWire/Handshake.hs
index 6f4598ae..ff768cae 100644
--- a/src/Network/BitTorrent/PeerWire/Handshake.hs
+++ b/src/Network/BitTorrent/PeerWire/Handshake.hs
@@ -11,6 +11,7 @@
11-- peer. 11-- peer.
12-- 12--
13{-# LANGUAGE OverloadedStrings #-} 13{-# LANGUAGE OverloadedStrings #-}
14{-# LANGUAGE RecordWildCards #-}
14module Network.BitTorrent.PeerWire.Handshake 15module Network.BitTorrent.PeerWire.Handshake
15 ( Handshake(..), handshakeCaps 16 ( Handshake(..), handshakeCaps
16 , handshake 17 , handshake
@@ -27,6 +28,8 @@ import Data.ByteString (ByteString)
27import qualified Data.ByteString as B 28import qualified Data.ByteString as B
28import qualified Data.ByteString.Char8 as BC 29import qualified Data.ByteString.Char8 as BC
29import Data.Serialize as S 30import Data.Serialize as S
31import Text.PrettyPrint
32
30import Network 33import Network
31import Network.Socket.ByteString 34import Network.Socket.ByteString
32 35
@@ -77,9 +80,9 @@ handshakeCaps :: Handshake -> Capabilities
77handshakeCaps = hsReserved 80handshakeCaps = hsReserved
78 81
79-- | Format handshake in human readable form. 82-- | Format handshake in human readable form.
80ppHandshake :: Handshake -> String 83ppHandshake :: Handshake -> Doc
81ppHandshake hs = BC.unpack (hsProtocol hs) ++ " " 84ppHandshake Handshake {..} =
82 ++ ppClientInfo (clientInfo (hsPeerID hs)) 85 text (BC.unpack hsProtocol) <+> ppClientInfo (clientInfo hsPeerID)
83 86
84-- | Get handshake message size in bytes from the length of protocol string. 87-- | Get handshake message size in bytes from the length of protocol string.
85handshakeSize :: Word8 -> Int 88handshakeSize :: Word8 -> Int