diff options
Diffstat (limited to 'src/Network/BitTorrent/Tracker/Protocol.hs')
-rw-r--r-- | src/Network/BitTorrent/Tracker/Protocol.hs | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/Network/BitTorrent/Tracker/Protocol.hs b/src/Network/BitTorrent/Tracker/Protocol.hs index 4e1262ed..b67b856d 100644 --- a/src/Network/BitTorrent/Tracker/Protocol.hs +++ b/src/Network/BitTorrent/Tracker/Protocol.hs | |||
@@ -23,9 +23,22 @@ | |||
23 | {-# LANGUAGE TemplateHaskell #-} | 23 | {-# LANGUAGE TemplateHaskell #-} |
24 | {-# OPTIONS -fno-warn-orphans #-} | 24 | {-# OPTIONS -fno-warn-orphans #-} |
25 | module Network.BitTorrent.Tracker.Protocol | 25 | module Network.BitTorrent.Tracker.Protocol |
26 | ( Event(..), AnnounceQuery(..), AnnounceInfo(..) | 26 | ( -- * Announce |
27 | , defaultNumWant , defaultPorts | 27 | Event(..) |
28 | , ScrapeQuery, ScrapeInfo(..) | 28 | , AnnounceQuery(..) |
29 | , AnnounceInfo(..) | ||
30 | |||
31 | -- ** Defaults | ||
32 | , defaultNumWant | ||
33 | , defaultPorts | ||
34 | |||
35 | -- * Scrape | ||
36 | , ScrapeQuery | ||
37 | , ScrapeInfo(..) | ||
38 | , Scrape | ||
39 | |||
40 | -- * TODO | ||
41 | , Tracker(..) | ||
29 | ) | 42 | ) |
30 | where | 43 | where |
31 | 44 | ||
@@ -325,6 +338,9 @@ data ScrapeInfo = ScrapeInfo { | |||
325 | 338 | ||
326 | $(deriveJSON (L.map toLower . L.dropWhile isLower) ''ScrapeInfo) | 339 | $(deriveJSON (L.map toLower . L.dropWhile isLower) ''ScrapeInfo) |
327 | 340 | ||
341 | -- | Scrape info about a set of torrents. | ||
342 | type Scrape = Map InfoHash ScrapeInfo | ||
343 | |||
328 | instance BEncodable ScrapeInfo where | 344 | instance BEncodable ScrapeInfo where |
329 | toBEncode ScrapeInfo {..} = fromAssocs | 345 | toBEncode ScrapeInfo {..} = fromAssocs |
330 | [ "complete" --> siComplete | 346 | [ "complete" --> siComplete |
@@ -357,3 +373,8 @@ instance Serialize ScrapeInfo where | |||
357 | , siIncomplete = fromIntegral leechers | 373 | , siIncomplete = fromIntegral leechers |
358 | , siName = Nothing | 374 | , siName = Nothing |
359 | } | 375 | } |
376 | |||
377 | -- | Set of tracker RPCs. | ||
378 | class Tracker s where | ||
379 | announce :: s -> AnnounceQuery -> IO AnnounceInfo | ||
380 | scrape_ :: s -> ScrapeQuery -> IO Scrape | ||