diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/BitTorrent/PeerWire/Handshake.hs | 15 | ||||
-rw-r--r-- | src/Network/BitTorrent/PeerWire/Message.hs | 5 | ||||
-rw-r--r-- | src/Network/BitTorrent/Tracker/Scrape.hs | 2 |
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 #-} |
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)) |
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 | -- | ||
136 | ppMessage :: Message -> String | 139 | ppMessage :: Message -> String |
137 | ppMessage (Bitfield _) = "Bitfield " | 140 | ppMessage (Bitfield _) = "Bitfield " |
138 | ppMessage (Piece blk) = "Piece " ++ ppBlock blk | 141 | ppMessage (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. |