From 271ff156ecfd7a7638d694a71d3eb9e4b87b2dcb Mon Sep 17 00:00:00 2001
From: erdgeist <>
Date: Fri, 19 Oct 2007 20:02:41 +0000
Subject: Those stupid "announce ?info_hash" torrents get really annoying. Fix
 it in announce and scrape.

---
 opentracker.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/opentracker.c b/opentracker.c
index 191d5d6..1725cd2 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -372,6 +372,11 @@ LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: s24s old\n", h->ip[0], h->ip[1], h->i
   case 6: /* scrape ? */
     if( byte_diff( data, 6, "scrape") ) HTTPERROR_404;
 
+  /* This is to hack around stupid clients that just replace
+     "announce ?info_hash" with "scrape ?info_hash".
+     We do not want to bomb them with full scrapes */
+    if( !byte_diff( c, 2, " ?" ) ) ++c;
+
 SCRAPE_WORKAROUND:
 
     scanon = 1;
@@ -414,6 +419,9 @@ write( 2, "\n", 1 );
   case 8:
     if( byte_diff( data, 8, "announce" ) ) HTTPERROR_404;
 
+  /* This is to hack around stupid clients that send "announce ?info_hash" */
+    if( !byte_diff( c, 2, " ?" ) ) ++c;
+
 ANNOUNCE_WORKAROUND:
 
     OT_SETIP( &peer, ((struct http_data*)io_getcookie( s ) )->ip );
-- 
cgit v1.2.3