From 2625c8b7a66c0245d1eacbe0076f04df6ae8acd8 Mon Sep 17 00:00:00 2001 From: joe Date: Fri, 8 Jun 2018 23:34:14 -0400 Subject: bittorrent: Easier constructor for TrackerList. --- bittorrent/src/Network/BitTorrent/Tracker.hs | 1 + bittorrent/src/Network/BitTorrent/Tracker/List.hs | 4 ++++ bittorrent/src/Network/BitTorrent/Tracker/RPC/HTTP.hs | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bittorrent/src/Network/BitTorrent/Tracker.hs b/bittorrent/src/Network/BitTorrent/Tracker.hs index 6db67559..1191f921 100644 --- a/bittorrent/src/Network/BitTorrent/Tracker.hs +++ b/bittorrent/src/Network/BitTorrent/Tracker.hs @@ -23,6 +23,7 @@ module Network.BitTorrent.Tracker , trackerList , Session , Event (..) + , trackers , newSession , closeSession , withSession diff --git a/bittorrent/src/Network/BitTorrent/Tracker/List.hs b/bittorrent/src/Network/BitTorrent/Tracker/List.hs index 0eb11641..1507b4be 100644 --- a/bittorrent/src/Network/BitTorrent/Tracker/List.hs +++ b/bittorrent/src/Network/BitTorrent/Tracker/List.hs @@ -16,6 +16,7 @@ module Network.BitTorrent.Tracker.List , TrackerList -- * Construction + , trackers , trackerList , shuffleTiers , mapWithURI @@ -116,6 +117,9 @@ fixList mxss mx = do let xss' = L.filter (not . L.null) xss return $ maybe xss' (addBackup xss') mx +trackers :: [URI] -> TrackerList () +trackers uris = TierList $ map (\uri -> [(uri,())]) uris + -- | Extract set of trackers from torrent file. The 'tAnnounce' key is -- only ignored if the 'tAnnounceList' key is present. trackerList :: Torrent -> TrackerList () diff --git a/bittorrent/src/Network/BitTorrent/Tracker/RPC/HTTP.hs b/bittorrent/src/Network/BitTorrent/Tracker/RPC/HTTP.hs index 44b123a3..6f7a53bf 100644 --- a/bittorrent/src/Network/BitTorrent/Tracker/RPC/HTTP.hs +++ b/bittorrent/src/Network/BitTorrent/Tracker/RPC/HTTP.hs @@ -129,7 +129,7 @@ fillRequest Options {..} q r = r httpTracker :: BEncode a => Manager -> URI -> SimpleQuery -> IO a httpTracker Manager {..} uri q = packHttpException $ do - request <- fillRequest options q <$> setUri defaultRequest {- http-client instance for Request -} uri + request <- fillRequest options q <$> setUri defaultRequest uri response <- runResourceT $ httpLbs request httpMgr case BE.decode $ BL.toStrict $ responseBody response of Left msg -> throwIO (ParserFailure msg) -- cgit v1.2.3