summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Tracker/Protocol.hs
diff options
context:
space:
mode:
authorSam T <pxqr.sta@gmail.com>2013-08-28 04:56:52 +0400
committerSam T <pxqr.sta@gmail.com>2013-08-28 04:56:52 +0400
commit03841eb1f2e8e0d38833b8855a55e393fb4d766a (patch)
treee693750cc126f529dcbbd3db8709f508a7f101bf /src/Network/BitTorrent/Tracker/Protocol.hs
parent54b20f9ac462105cd3857b9c8102954a725ef308 (diff)
~ Adapt HTTP Tracker to new interface.
Diffstat (limited to 'src/Network/BitTorrent/Tracker/Protocol.hs')
-rw-r--r--src/Network/BitTorrent/Tracker/Protocol.hs16
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
45import Control.Applicative 46import Control.Applicative
47import Control.Exception
46import Control.Monad 48import Control.Monad
47
48import Data.Aeson.TH 49import Data.Aeson.TH
49import Data.Char as Char 50import Data.Char as Char
50import Data.Map as M 51import Data.Map as M
@@ -58,12 +59,11 @@ import Data.Text.Encoding
58import Data.Serialize hiding (Result) 59import Data.Serialize hiding (Result)
59import Data.URLEncoded as URL 60import Data.URLEncoded as URL
60import Data.Torrent.Metainfo 61import Data.Torrent.Metainfo
61
62import Network 62import Network
63import Network.URI
63import Network.Socket 64import Network.Socket
64 65
65import Network.BitTorrent.Peer 66import Network.BitTorrent.Peer
66import 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.
367class Tracker s where 367class 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--
374scrapeOne :: Tracker t => t -> InfoHash -> IO ScrapeInfo
375scrapeOne 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"