diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-08-28 04:56:52 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-08-28 04:56:52 +0400 |
commit | 03841eb1f2e8e0d38833b8855a55e393fb4d766a (patch) | |
tree | e693750cc126f529dcbbd3db8709f508a7f101bf /src/Network/BitTorrent/Tracker/Protocol.hs | |
parent | 54b20f9ac462105cd3857b9c8102954a725ef308 (diff) |
~ Adapt HTTP Tracker to new interface.
Diffstat (limited to 'src/Network/BitTorrent/Tracker/Protocol.hs')
-rw-r--r-- | src/Network/BitTorrent/Tracker/Protocol.hs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/Network/BitTorrent/Tracker/Protocol.hs b/src/Network/BitTorrent/Tracker/Protocol.hs index 3f264aed..965f3480 100644 --- a/src/Network/BitTorrent/Tracker/Protocol.hs +++ b/src/Network/BitTorrent/Tracker/Protocol.hs | |||
@@ -39,12 +39,13 @@ module Network.BitTorrent.Tracker.Protocol | |||
39 | 39 | ||
40 | -- * TODO | 40 | -- * TODO |
41 | , Tracker(..) | 41 | , Tracker(..) |
42 | , scrapeOne | ||
42 | ) | 43 | ) |
43 | where | 44 | where |
44 | 45 | ||
45 | import Control.Applicative | 46 | import Control.Applicative |
47 | import Control.Exception | ||
46 | import Control.Monad | 48 | import Control.Monad |
47 | |||
48 | import Data.Aeson.TH | 49 | import Data.Aeson.TH |
49 | import Data.Char as Char | 50 | import Data.Char as Char |
50 | import Data.Map as M | 51 | import Data.Map as M |
@@ -58,12 +59,11 @@ import Data.Text.Encoding | |||
58 | import Data.Serialize hiding (Result) | 59 | import Data.Serialize hiding (Result) |
59 | import Data.URLEncoded as URL | 60 | import Data.URLEncoded as URL |
60 | import Data.Torrent.Metainfo | 61 | import Data.Torrent.Metainfo |
61 | |||
62 | import Network | 62 | import Network |
63 | import Network.URI | ||
63 | import Network.Socket | 64 | import Network.Socket |
64 | 65 | ||
65 | import Network.BitTorrent.Peer | 66 | import Network.BitTorrent.Peer |
66 | import Network.BitTorrent.Sessions.Types | ||
67 | 67 | ||
68 | {----------------------------------------------------------------------- | 68 | {----------------------------------------------------------------------- |
69 | Announce messages | 69 | Announce messages |
@@ -365,5 +365,13 @@ instance Serialize ScrapeInfo where | |||
365 | 365 | ||
366 | -- | Set of tracker RPCs. | 366 | -- | Set of tracker RPCs. |
367 | class Tracker s where | 367 | class Tracker s where |
368 | connect :: URI -> IO s | ||
368 | announce :: s -> AnnounceQuery -> IO AnnounceInfo | 369 | announce :: s -> AnnounceQuery -> IO AnnounceInfo |
369 | scrape_ :: s -> ScrapeQuery -> IO Scrape | 370 | scrape :: s -> ScrapeQuery -> IO Scrape |
371 | |||
372 | -- | More particular version of 'scrape', just for one torrent. | ||
373 | -- | ||
374 | scrapeOne :: Tracker t => t -> InfoHash -> IO ScrapeInfo | ||
375 | scrapeOne uri ih = scrape uri [ih] >>= maybe err return . M.lookup ih | ||
376 | where | ||
377 | err = throwIO $ userError "unable to find info hash in response dict" | ||