1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Network.BitTorrent.Tracker.TestData
( TrackerEntry (..)
, isUdpTracker
, isHttpTracker
, trackers
) where
import Data.Maybe
import Data.String
import Network.URI
import Data.Torrent.InfoHash
data TrackerEntry = TrackerEntry
{ -- | May be used to show tracker name in test suite report.
trackerName :: String
-- | Announce uri of the tracker.
, trackerURI :: URI
-- | Some trackers abadoned, so don't even try to announce.
, tryAnnounce :: Bool
-- | Some trackers do not support scraping, so we should not even
-- try to scrape them.
, tryScraping :: Bool
-- | Some trackers allow
, hashList :: Maybe [InfoHash]
}
isUdpTracker :: TrackerEntry -> Bool
isUdpTracker TrackerEntry {..} = uriScheme trackerURI == "udp:"
isHttpTracker :: TrackerEntry -> Bool
isHttpTracker TrackerEntry {..} = uriScheme trackerURI == "http:"
|| uriScheme trackerURI == "https:"
instance IsString URI where
fromString str = fromMaybe err $ parseURI str
where
err = error $ "fromString: bad URI " ++ show str
trackerEntry :: URI -> TrackerEntry
trackerEntry uri = TrackerEntry
{ trackerName = maybe "<unknown>" uriRegName (uriAuthority uri)
, trackerURI = uri
, tryAnnounce = False
, tryScraping = False
, hashList = Nothing
}
announceOnly :: String -> URI -> TrackerEntry
announceOnly name uri = (trackerEntry uri)
{ trackerName = name
, tryAnnounce = True
}
announceScrape :: String -> URI -> TrackerEntry
announceScrape name uri = (announceOnly name uri)
{ tryScraping = True
}
notWorking :: String -> URI -> TrackerEntry
notWorking name uri = (trackerEntry uri)
{ trackerName = name
}
trackers :: [TrackerEntry]
trackers =
[ announceOnly "LinuxTracker"
"http://linuxtracker.org:2710/00000000000000000000000000000000/announce"
-- from "http://www.linux23.com/"
, announceScrape "Arch" "http://tracker.archlinux.org:6969/announce"
, notWorking "rarbg" "udp://9.rarbg.com:2710/announce"
, announceScrape "OpenBitTorrent" "udp://tracker.openbittorrent.com:80/announce"
, announceScrape "PublicBT" "udp://tracker.publicbt.com:80/announce"
, notWorking "OpenBitTorrent" "http://tracker.openbittorrent.com:80/announce"
, notWorking "PublicBT" "http://tracker.publicbt.com:80/announce"
]
|