How to set up a private BitTorrent tracker.
The software and documentation on the web that I can find on this topic sucks. Big time. The vast majority of people using BitTorrent are pirates. I just want it to blast my own software across a large (more than 100) number of servers quickly. In this document, I'll post what I can figure out. Feel free to chime in if I get any of this wrong.
To set up a BitTorrent ecosystem, you need a few things:
Some files in a directory.
A BitTorrent tracker program. This runs on the server with the "master" copies of the files to distribute and is how updates get propagated to the clients.
A bunch of BitTorrent clients. These run on each target machine in the network to download updates from the tracker and from each other.
A torrent file, which describes the files the tracker is making available.
You put the files in some directory on the master server; then create a torrent file; start the tracker specifying the torrent file. Then you run the clients on all the machine in the network, and point them at the initial tracker and it's torrent file. Then, boom, everything gets sprayed all over the LAN.
As I've written before, BitTorrent software is a mess. The original BT software is a sordid mess that depends on layers of Python extensions. The documentation pretty much blows, and is geared toward the pirate user who is basically looking for a way to download the latest music video. I found what looks like a pretty clean tracker implementation. It's old school; a C-language program that depends on one other library, a nice C-language daemon framework.
Unfortunately, the documentation for opentracker is virtually non-existent. It seems to assume that you know all about torrents and trackers, which I pretty much don't. So I'll write what I figure out here.
I'm quite encouraged by this, because it actually worked perfectly as advertised. These commands worked perfectly for me on CentOS Linux 5 and Mac OS X 10.5.
Set up files
I made a directory called /usr/local/torrents and I put a big file in it. I randomly chose the Firefox Mac distribution, and called it "firefox.dmg." Exciting.
Create the torrent.
I used "createtorrent" to do this. Createtorrent is a utility you can get from ports or debian packages. It is very easy to build and install.
% createtorrent -a http://buffy.ma.runwaynine.com firefox.dmg firefox.torrent
computing sha1... done
% ls -l
-[email protected] 1 root wheel 17669478 May 22 14:18 firefox.dmg
-rw-r--r-- 1 root wheel 1506 May 22 14:20 firefox.torrent
% opentracker -p 6881 -d /usr/local/torrents
That was easy. OK, now I'll go over to my bittorrent client and try to get the torrent. This is where I find BT a bit weird, and it probably means I really don't understand what's going on here. I would think the BT client would allow me to connect to the tracker I just started running, and start seeding/downloading the file. But I don't know what URL to connect to on the opentracker. If I open the firefox.torrent file directly with my BT client, it looks like this:
But it just sits there, waiting to start downloading. I don't know why it won't start seeding from the tracker. Hmm.
I just found a really good document. Finally. See the next post.