diff options
-rw-r--r-- | src/Network/BitTorrent/Tracker/Message.hs | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/src/Network/BitTorrent/Tracker/Message.hs b/src/Network/BitTorrent/Tracker/Message.hs index dc8794b6..17871133 100644 --- a/src/Network/BitTorrent/Tracker/Message.hs +++ b/src/Network/BitTorrent/Tracker/Message.hs | |||
@@ -35,15 +35,6 @@ module Network.BitTorrent.Tracker.Message | |||
35 | , ParamParseFailure | 35 | , ParamParseFailure |
36 | , parseAnnounceQuery | 36 | , parseAnnounceQuery |
37 | 37 | ||
38 | -- ** Request | ||
39 | , AnnounceQueryExt (..) | ||
40 | , renderAnnounceQueryExt | ||
41 | , parseAnnounceQueryExt | ||
42 | |||
43 | , AnnounceRequest (..) | ||
44 | , parseAnnounceRequest | ||
45 | , renderAnnounceRequest | ||
46 | |||
47 | -- ** Info | 38 | -- ** Info |
48 | , PeerList (..) | 39 | , PeerList (..) |
49 | , getPeerList | 40 | , getPeerList |
@@ -63,9 +54,21 @@ module Network.BitTorrent.Tracker.Message | |||
63 | , ScrapeInfo | 54 | , ScrapeInfo |
64 | 55 | ||
65 | -- * HTTP specific | 56 | -- * HTTP specific |
66 | , RawPath | 57 | -- ** Routes |
58 | , PathPiece | ||
67 | , defaultAnnouncePath | 59 | , defaultAnnouncePath |
68 | , defaultScrapePath | 60 | , defaultScrapePath |
61 | |||
62 | -- ** Request | ||
63 | , AnnounceQueryExt (..) | ||
64 | , renderAnnounceQueryExt | ||
65 | , parseAnnounceQueryExt | ||
66 | |||
67 | , AnnounceRequest (..) | ||
68 | , parseAnnounceRequest | ||
69 | , renderAnnounceRequest | ||
70 | |||
71 | -- ** Response | ||
69 | , announceType | 72 | , announceType |
70 | , scrapeType | 73 | , scrapeType |
71 | , parseFailureStatus | 74 | , parseFailureStatus |
@@ -113,14 +116,20 @@ import Network.BitTorrent.Core | |||
113 | -- Events | 116 | -- Events |
114 | -----------------------------------------------------------------------} | 117 | -----------------------------------------------------------------------} |
115 | 118 | ||
116 | -- | Events used to specify which kind of announce query is performed. | 119 | -- | Events are used to specify which kind of announce query is performed. |
117 | data Event = Started | 120 | data Event |
118 | -- ^ For the first request: when a peer join the swarm. | 121 | -- | For the first request: when download first begins. |
119 | | Stopped | 122 | = Started |
120 | -- ^ Sent when the peer is shutting down. | 123 | |
121 | | Completed | 124 | -- | This peer stopped downloading /and/ uploading the torrent or |
122 | -- ^ To be sent when the peer completes a download. | 125 | -- just shutting down. |
123 | deriving (Show, Read, Eq, Ord, Enum, Bounded, Typeable) | 126 | | Stopped |
127 | |||
128 | -- | This peer completed downloading the torrent. This only happen | ||
129 | -- right after last piece have been verified. No 'Completed' is | ||
130 | -- sent if the file was completed when 'Started'. | ||
131 | | Completed | ||
132 | deriving (Show, Read, Eq, Ord, Enum, Bounded, Typeable) | ||
124 | 133 | ||
125 | $(deriveJSON omitRecordPrefix ''Event) | 134 | $(deriveJSON omitRecordPrefix ''Event) |
126 | 135 | ||
@@ -186,11 +195,13 @@ data AnnounceQuery = AnnounceQuery | |||
186 | -- tracker throught a proxy. | 195 | -- tracker throught a proxy. |
187 | , reqIP :: Maybe HostAddress | 196 | , reqIP :: Maybe HostAddress |
188 | 197 | ||
189 | -- | Number of peers that the peers wants to receive from. See | 198 | -- | Number of peers that the peers wants to receive from. It is |
190 | -- note for 'defaultNumWant'. | 199 | -- optional for trackers to honor this limit. See note for |
200 | -- 'defaultNumWant'. | ||
191 | , reqNumWant :: Maybe Int | 201 | , reqNumWant :: Maybe Int |
192 | 202 | ||
193 | -- | If not specified, the request is regular periodic request. | 203 | -- | If not specified, the request is regular periodic |
204 | -- request. Regular request should be sent | ||
194 | , reqEvent :: Maybe Event | 205 | , reqEvent :: Maybe Event |
195 | } deriving (Show, Eq, Typeable) | 206 | } deriving (Show, Eq, Typeable) |
196 | 207 | ||
@@ -621,12 +632,12 @@ defaultMaxNumWant = 200 | |||
621 | defaultReannounceInterval :: Int | 632 | defaultReannounceInterval :: Int |
622 | defaultReannounceInterval = 30 * 60 | 633 | defaultReannounceInterval = 30 * 60 |
623 | 634 | ||
624 | type RawPath = BS.ByteString | 635 | type PathPiece = BS.ByteString |
625 | 636 | ||
626 | defaultAnnouncePath :: RawPath | 637 | defaultAnnouncePath :: PathPiece |
627 | defaultAnnouncePath = "announce" | 638 | defaultAnnouncePath = "announce" |
628 | 639 | ||
629 | defaultScrapePath :: RawPath | 640 | defaultScrapePath :: PathPiece |
630 | defaultScrapePath = "scrape" | 641 | defaultScrapePath = "scrape" |
631 | 642 | ||
632 | missingOffset :: Int | 643 | missingOffset :: Int |