Hacking opentracker to run on your home server

opentracker is probably the most famous BitTorrent tracker around. There are several public tackers that anyone can use (PublicBitTorrent, OpenBitTorrent) but you may want to run a tracker yourself. If you’re computer is on a home network behind a NAT router this can cause a problem if you want to allow your local machines share torrents with other users external to your private network.

When a local BitTorrent client connects to your local opentracker server the ip address seen by the tracker will be the private ip address of your router like or When other external clients connect to the tracker that local ip address won’t do them any good. Those external clients need to know your public ip address.

We can modify opentracker to store your public ip address whenever it detects your private ip address. Start by adding two new configuration values to your opentracker.conf file.


Now edit opentracker.c and add global definitions for the public and private ip address.

/* Globals */
time_t       g_now_seconds;
char *       g_redirecturl;
char *       g_publicip;
char *       g_privateip;
// other code not shown...

Next edit opentracker.c and look for the parse_configfile function. Add the conditions to read in the new private_ip and public_ip values.

/* Scan for commands */
if(!byte_diff(p,15,"tracker.rootdir" ) && isspace(p[15])) {
set_config_option( &g_serverdir, p+16 );
} else if(!byte_diff(p,17,"tracker.public_ip" ) && isspace(p[17])) {
set_config_option( &g_publicip, p+18 );
} else if(!byte_diff(p,18,"tracker.private_ip" ) && isspace(p[18])) {
set_config_option( &g_privateip, p+19 );
// other code not shown...

Now edit ot_http.c and add an extern reference to the public and private ip variables.

extern char *g_redirecturl;
extern char *g_publicip;
extern char *g_privateip;
// other code now shown...

Next edit ot_http.c and look for the http_handle_announce function. This is where we’ll add the code to look for the private ip address and replace it with the public one.

  ws->peer_id = NULL;
  ws->hash = NULL;

  OT_SETIP( &ws->peer, cookie->ip );

  // Check if this is a local peer
  ot_ip6 tmpprivateip;
  scan_ip6( g_privateip, tmpprivateip );

  if( memcmp( tmpprivateip, cookie->ip, sizeof(ot_ip6) ) == 0 )
	  ot_ip6 tmppublicip;
      scan_ip6( g_publicip, tmppublicip );

      char _debug[512];
      int off = snprintf( _debug, sizeof(_debug), "Found private ip, setting public ip:" );
	  off += fmt_ip6c( _debug+off, tmppublicip );
	  off += snprintf( _debug+off, sizeof(_debug)-off, "\n" );
      write( 2, _debug, off );

      // Override the local ip address
	  OT_SETIP( &ws->peer, tmppublicip );
// other code not shown...

Compile opentracker normally and you should be able to see the debug message when a local client connects to your tracker. Warning: This modification works for me (on my machine). It has not been throughly tested.

Samsung LCD TV Purple Dot Power Issues

A few weeks ago my Samsung 46″ LCD TV starting acting up. It’s just over two years old (Model Number LN-T4665F), but that’s long enough to be out of the warranty period. Every once in a while purple dots would cover the picture, but if you turned the TV off and then back on, the dots would go away.

Right around the same time the TV had another issue where it would power on a couple times before the picture would actually appear on the screen. The Samsung plays a start up sound when you first press power on your remote. Normally the picture appears shortly after the start up sound, but my TV would play the sound two or three times before the picture would appear.

A Google search turned up a number of people with the same symptoms. AVS Forum has a huge thread on this series of Samsung LCD’s, and includes a bunch of advice on how to fix the problem. Long story short, you need to replace some bad capacitors on the power supply board.

Step one is opening up the TV. There are a bunch of screws to remove on the back, don’t forget the big wall mount bolts. Here’s a picture with the back cover removed.

And here is a close up of the bad capacitors.

I replaced three of these (total cost was < $6 at Fry’s). The bad ones are the medium sized black capacitors with a bulge on top. I put everything back together and the TV is working great!

UPDATE: Several readers have been able to get Samsung to fix this issue even if your set is out of warranty. Read the comments below for more information.

Updated audiostreamer-meta project

I’ve updated the audiostream-meta project hosted on Google Code to include all the updates I’ve made to the original AudioStreamer example from Matt Gallagher. In addition to parsing audio stream metadata the latest code will play AAC and AAC+ V1 (thanks to Brian Stormont) streams. The stream bitrate is also detected and displayed, along with the metadata, on the sample view.


Stream.ly Radio 1.5

The next version of Streamly Radio has been submitted to Apple for review. I’m excited about this release. I feel like this next version really cleans up the interface and adds some great features. You’ll now be able to search the radio directory and Live365 members can enter their username & password in the Settings app so they can play even more Live365 stations. The Live365 login feature came about from a four year old [!] blog post by a guy named Jim Russell. Thanks Jim!

I’ve removed the Twitter/Song.ly integration from this new release. That feature has always felt half-baked to me anyway. It’s easy to get excited about integrating everything (Twitter, Facebook, etc., etc.) into an iPhone app, but Stream.ly is about streaming radio, so that’s where I want to focus future development.