summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Network/BitTorrent/PeerWire/Handshake.hs15
-rw-r--r--src/Network/BitTorrent/PeerWire/Message.hs5
-rw-r--r--src/Network/BitTorrent/Tracker/Scrape.hs2
3 files changed, 13 insertions, 9 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))
diff --git a/src/Network/BitTorrent/PeerWire/Message.hs b/src/Network/BitTorrent/PeerWire/Message.hs
index e833ba03..3f6647dd 100644
--- a/src/Network/BitTorrent/PeerWire/Message.hs
+++ b/src/Network/BitTorrent/PeerWire/Message.hs
@@ -132,7 +132,10 @@ instance Serialize Message where
132 put (AllowedFast ix) = putInt 5 >> putWord8 0x11 >> putInt ix 132 put (AllowedFast ix) = putInt 5 >> putWord8 0x11 >> putInt ix
133 133
134 134
135-- | Compact output for logging: only useful information but not payload bytes. 135-- | Format messages in human readable form. Note that output is
136-- compact and suitable for logging: only useful information but not
137-- payload bytes.
138--
136ppMessage :: Message -> String 139ppMessage :: Message -> String
137ppMessage (Bitfield _) = "Bitfield " 140ppMessage (Bitfield _) = "Bitfield "
138ppMessage (Piece blk) = "Piece " ++ ppBlock blk 141ppMessage (Piece blk) = "Piece " ++ ppBlock blk
diff --git a/src/Network/BitTorrent/Tracker/Scrape.hs b/src/Network/BitTorrent/Tracker/Scrape.hs
index 49451a57..c3f4ee64 100644
--- a/src/Network/BitTorrent/Tracker/Scrape.hs
+++ b/src/Network/BitTorrent/Tracker/Scrape.hs
@@ -5,7 +5,7 @@
5-- Stability : experimental 5-- Stability : experimental
6-- Portability : portable 6-- Portability : portable
7-- 7--
8-- By convention most trackers support anouther form of request, 8-- By convention most trackers support another form of request,
9-- which queries the state of a given torrent (or all torrents) that the 9-- which queries the state of a given torrent (or all torrents) that the
10-- tracker is managing. This module provides a way to easily request 10-- tracker is managing. This module provides a way to easily request
11-- scrape info for a particular torrent list. 11-- scrape info for a particular torrent list.