mod_bt - Making things better for seeders
Documentation
- Introduction
- System Requirements
- Components
- Installation
- Configuration
- Utilities
- btt_db2xml - Database backup
- btt_xml2db - Database recovery
- btt_infohash - Edit infohash data
- bt_showmetainfo - Show metainfo file details
-
Language Bindings:
-
PHP:
- php_mod_bt: PHP Interface to mod_bt under apache2.
-
Perl:
- Apache::ModBT - Apache::ModBT - mod_perl interface to mod_bt
- Net::BitTorrent::LibBT::Tracker - Manipulate a tracker running under libbttracker from perl.
- Code Examples:
- Apache::ModBT::LeechNuker - Example mod_perl handler to shun leeches.
- Perl source for Apache::ModBT::LeechNuker
- bttrack.pl - Example perl script that uses Net::BitTorrent::LibBT::Tracker to act as a tracker.
- Perl source for bttrack.pl
-
PHP:
- Crash Recovery
- Reporting Bugs
- Version History
- To Do
- License
Introduction
mod_bt turns your Apache 2 webserver into a BitTorrent tracker. Instead of running a webserver, running a tracker, and running expensive code to parse the tracker's statistics and produce an HTML webpage, you can run it all in one process. Direct access to the tracker's operating details is given via PHP and Perl language bindings, so your webpage doesn't have to spend time doing expensive transactions like bdecoding to get at statistics.
System Requirements
- libdb-4.2 or 4.3
- Apache 2.x (only the Apache Portability Runtime library is required for libbttracker; mod_bt requires apache2 as well.)
- Packages that enhance mod_bt:
Components
The mod_bt distribution is broken down into modular pieces with the goals of maximum flexability and portability in mind.
- libbttracker is the BitTorrent Tracker Library. It handles all of the logic involved with the parsing of requests and the formulation of replies. db-4.2 is used by this library for data management. The library does not do any actual socket or HTTP protocol handling itself. Instead, functions are provided that receive connection data (remote ip, URL query strings, etc) and return the appropriate data to return to the clients.
- libbtutil is the BitTorrent Utility Library. It holds code that is useful to BitTorrent trackers, peers, and tools, such as parsing metainfo (.torrent) files, and correctly formatting values like infohashes and file sizes.
- mod_bt is the module that connects libbttracker with the Apache 2.x webserver. Aside from some maintenance work (opening/closing the database on apache's startup/shutdown, etc), this module merely accepts connection information from apache2, sends it to libbttracker, and then sends libbttracker's response back to apache.
Crash Recovery
As with most databases, the mod_bt tracker database is less likely to
become corrupted after a system crash if the hard drive it is stored on
does not have write cacheing enabled. Under linux, you can disable a drive's
write-cache on startup using the "hdparm" command (eg; hdparm -W0 /dev/hda
).
Normally, mod_bt will recover a crashed database without problems when the server starts up. If the tracker was heavily trafficked for a long time without a restart, it may take several minutes for the database recovery to complete. To lower this delay, you should restart your apache server at least once a day. (You're already doing that to rotate your logs anyway, right??)
Here's what to do if your database crashes and apache can't start up:
- Make sure apache/mod_bt is not running.
- Go into the Tracker's data directory.
- Run the
db_recover
program that comes with libdb to recover the database. (On my Debian system with libdb-4.3, it's calleddb4.3_recover
) - Remove the
peersindex
andpeers
files from the directory. - Start up apache/mod_bt
- Make sure nothing nasty turns up in apache's
error_log
If the recovery successful, you should still have all of your infohashes online, with all of their statistics/other info still intact.
The peerlists for each infohash will have been deleted, but any active peers will reregister themselves within return_interval
seconds.
If the recovery was not successful, remove all of the files in the tracker's home directory. If you have been creating backups with btt_db2xml, you can recover your latest backup with btt_xml2db. If you haven't been keeping backups (shame on you!), your only option is to delete all of the files in the tracker's home directory, re-register your torrents, and start fresh.
Reporting Bugs
Bug reports should be submitted via email to the mod_bt Bug Tracking System. See http://bts.yi.org/bugs/mod_bt for more details.
To Do
If you want are able to help, please see the developers page.
-
Create a DTD to describe the output of
btt_db2xml
- Make mod_bt thread safe so that you aren't required to use the prefork MPM.
-
Command-line utilites:
- Change TOS of peers (shielded, shunned, etc)
- Implicit infohash registration by placing a .torrent in a directory (Probably a mod_perl2 handler that sits on top of /announce)
- Better documentation
- Passive peering - thanks to transmission this may soon become a reality.
- Python, Ruby, and SpiderMonkey language bindings.
License
mod_bt 0.0.19 Copyright 2004, 2005, 2006 Tyler MacDonald <tyler@yi.org> Website Design Copyright 2006 Donna M. Jaggard <donna@arwen.org> Small block of code in src/apache2/mod_bt.c Copyright Ralf S. Engelschall Licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.