mod_bt - Making things better for seeders
Documentation
Configuration
httpd.conf example
The "etc/httpd.conf" file in the mod_bt distribution provides a functioning example. At the very least, you will have to make a directory for mod_bt's data files to live and specify that to apache as "TrackerHome", as well as setting up your content-handlers at their appropriate URLs.
Apache Configuration Directives
The following directives may be used in an httpd.conf file to configure the tracker:
-
Tracker
Flag; Set to "On" to enable the BitTorrent tracker system, or "Off" to disable it. (Default: Off)
-
TrackerHome
Directory that mod_bt should use to store its data files. This directory must exist, be writable by the webserver, and ideally shouldn't be used for anything else. (Default: /tmp/tracker)
-
TrackerFlags
Set boolean tracker options - Prefix with a "-" to turn off, "+" (or nothing) to turn on
- RequireReg - Infohash Registration Required (Default: Off)
- AllowScrapeFull - Full Scrape Allowed (Default: On)
- AllowScrapeVerbose - Verbose Scrape Allowed (Default: On)
- AllowScrapeXML - XML Scrape Allowed (Default: On)
- AllowScrapeGeneral - General Scrape Allowed (Default: On)
-
TrackerStyleSheet
Stylesheet URL to use for generated HTML pages (Default: /mod_bt.css)
-
TrackerDetailURL
URL to link infohashes to from the HTML info page. The URL is handled in one of three differnt ways, depending on the last character in it:
- Link to actual file: If the URL ends with a "/" (slash), a link is only generated if the infohash has a filename, and the infohash's filename is appended to the URL.
- Link to .torrent: If the URL ends with a "." (dot), a link is only generated if the infohash has a filename, and the dot is replaced with the infohash's filename, followed by ".torrent"
- Link to statistics: If the URL ends with anything else, "?info_hash=", followed by the (uri-escaped) 20-byte infohash string, is appended to the URL. (See modbt-details handler below)
(Default: an empty string, which causes no links to be generated.) -
TrackerRootInclude
URL to include into the root HTML info page. (Default: None). An
<!--#include virtual="..." -->
line will be generated after the tracker info, but before the infohash listing, with this value if specified.Example:
TrackerRootInclude /motd.inc <LocationMatch "^/$"> SetHandler modbt-root Options +Includes SetOutputFilter INCLUDES </LocationMatch>
-
TrackerReturnPeers
Default number of peers to return on an /announce request (Default: 50)
-
TrackerReturnMax
Maximum number of peers to return on an /announce request (Default: 500)
-
TrackerReturnInterval
Number of seconds to tell peers to wait before using /announce again (Default: 600)
-
TrackerReturnPeerFactor
This value is used to increase peers' return intervals as more peers are added to an infohash. The following formula is used to calculate what interval to return to a peer:
peer.return_interval = ((tracker.return_peer_factor / infohash.peers) + 1) * tracker.return_interval
So, with a tracker
TrackerReturnInterval
of 500 seconds, and aTrackerReturnPeerFactor
of 20,- An infohash with 10 peers would tell it's peers to return every 500 seconds,
- an infohash with 22 peers would tell it's peers to return every 1000 seconds,
- An infohash with 1000 peers would tell it's peers to return every 500000 seconds,
- etc.
The default
TrackerReturnPeerFactor
setting is 1000. Setting it below 100 would probably cause problems on very popular torrents. -
TrackerHashWatermark
If there are less than this many hashes, only dead hashes are deleted; if there are more, inactive ones are deleted too (Default: 500)
-
TrackerHashMinAge
How many seconds of inactivity until a hash is considered inactive (Default: 1800)
-
TrackerHashMaxAge
How many seconds of inactivity until a hash is considered dead (Default: 3600)
Content Handlers
modbt-announce
Handler for BitTorrent peer announce requests.
Extensions:
-
shield=1
- When set, peer is considered "shielded".When a shielded peer is a seed, it is only served to other peers if there are no unshielded seeds available. This flag should be used for "core" seeds only, to protect their bandwidth when there are other sources of the data available. Using mod_rewrite, you can both protect access to the "shield" option, and cause it to be automatically set on peers that should be shielded without their software having to be modified. Here is an example:
<IfModule mod_rewrite.c> RewriteEngine On # Don't allow people to set shield mode themselves RewriteCond %{QUERY_STRING} ^.*shield=1 RewriteRule (.*) - [F] # Auto-Activate shield mode on peers that are known to be good seeders RewriteCond %{QUERY_STRING} !^.*shield=1 RewriteCond %{REMOTE_ADDR} ^10.20.30.40 [OR] RewriteCond %{REMOTE_ADDR} ^20.30.40.50 RewriteRule (.*) /announce?shield=1 [PT,L,QSA,NE,NS] </IfModule>
modbt-scrape
Handler for BitTorrent scrape requests
Extensions:
Only one of "xml=1", "verbose=1", or "html=1" may be specified.
-
info_hash=...[&info_hash=....[...]]
- Multiple "info_hash" parameters may be passed to /scrape, in which case only the details for the hashes specified will be displayed. -
xml=1
- Return results in an XML-like format rather than bencoded. The XML format contains a lot of additional information about the hash that is not supplied in the bencode, such as the last time we heard from a peer, total hits to /announce, etc. -
verbose=1
- Return the file's name and size in the bencode in addition to the standard "completed/downloaded/incomplete" statistics. -
html=1
- Return an HTML information page about the hashes rather than a bencode. -
full=1
- Display information about all hashes, not ones that have been active recently.
modbt-root
Return an HTML information page about the hashes. (Equivalent to calling the "modbt-scrape" handler with "html=1" appended to the URL arguments supplied by the user.)
modbt-register
Handler for Infohash registration.
When called with no arguments, a HTML page is displayed allowing the user to fill out the arguments required to register a hash.
This URL is more for use by administration scripts than actual users, but has an HTML interface to facilitate manual use as well.
Arguments:
filesize=...
- Size of the file this torrent refers to, in bytes.filename=...
- Name of the file this torrent refers to.info_hash=...
- Binary representation of the info_hash for this torrent.info_hash_str=...
- (For user input) hexadecimal representation of the info_hash for this torrent, as displayed by the HTML info pages.
- "filesize" and "filename" must always be specified before "info_hash" or "info_hash_str".
- Multiple "info_hash" or "info_hash_str" parameters may be specified.
- When an "info_hash" or "info_hash_str" parameter is encountered, the hash is registered using the "filesize" and "filename" parameters specified closest to the left of the "info_hash" parameter.
modbt-details
Handler for Infohash details.
The modbt-details handler generates an HTML page giving some information about an infohash, as well as an HTML listing of all of the peers currently considered to be part of the infohash. This handler can be bandwidth expensive on very popular torrents.
Arguments:
info_hash=...
- The infohash that you wish to display details for.
Example:
TrackerDetailURL /details <Location "/details"> SetHandler modbt-details </Location>