Troydm's Blog

A personal blog about software development

Hosting Your Own Remote Private Torrent Tracker

TL;DR Modifying BitTorrent Tracker written in C++

Ever wanted to share a really big file (more than 4 GB) with someone without a hassle of uploading it to some file upload server?

BitTorrent to rescue, also there are alternatives like hosting your own ftp/sftp file server but I won’t consider them here! So you probably already have a dedicated home file server running on Linux/BSD/Solaris that also has a torrent client installed on it that you access through web interface?

Oh you don’t? Snap it’s it’s so useful that nowadays almost everyone has some kind of NAS that he/she is using for file storage and torrents. So if you don’t have one then you are behind of times

So what do we need to share some file over torrent? Yes indeed we need a torrent tracker

The Pirate Bay

You probably heard of the famous pirate bay arrr!… haven’t you? Well pirate bay has a torrent tracker and you don’t. So you either have a choice and become a pirate bay resident and upload your torrent on their site or you can host your own little pirate bay just for you and your friends only

Most torrent clients include torrent tracker functionality out of the box but let’s consider our little case were we a have headless home server with torrent client that has only web interface and no torrent tracker So what do we do? We run our own standalone torrent tracker!

So that’s how I’ve ended on this page

My first choice was opentracker which is a very popular tracker that even pirate bay uses on their servers. First thing I did I’ve compiled and configured it in few mins and had it running on my 6969 port. So the next thing I’ve created a torrent with my torrent tracker announce url specified as **http://192.168.0.x:6969/announce** using mktorrent and added it to my torrent client which started seeding it right away. The next step I’ve created the same torrent file with announce url changed to my external ip and sent it to my friend! My friend started his torrent client and added the torrent. He could see that it had one seeder but still couldn’t download the file. Simple troubleshooting revealed that my torrent tracker was listing my seeder peer with a local network ip address that my friend’s torrent client couldn’t connect to…

Crying Loli

I knew now what I needed from torrent tracker. My port was the same but my ip address should be external instead of internal. I needed local ip substituted with remote ip for all external network peers. The peer port would remain the same since i have the same port forwarded.

Unfortunately I couldn’t find any functionality in opentracker that would do that :(

So next thing I did I’ve downloaded udpt and had it compiled. It uses udp tracker protocol which is much more network efficient. udpt is much more smaller than opentracker in both source code and functionality and thus was ideal to experiment with.

Adding the needed functionality didn’t solved my problem because udpt had some other bugs that I had to track down but in a few hours i had everything up and working! In the end I had a fully working private torrent tracker that was doing what I was hoping for. I’ve even added code to run it as linux daemon thanks to this little howto

My experimental fork is at this repository

Pirate Loli

Happy torrenting pirates!

Comments