summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerdgeist <>2007-10-19 22:13:59 +0000
committererdgeist <>2007-10-19 22:13:59 +0000
commitc59e44ba94abc0346f6b8fa33c6cbe8c4dfcab23 (patch)
tree2dc8012f455940fe321327e7fc7de6e3a55d81e4
parent41019c79d802e9bc6c1d70e573b6f31f50765ad7 (diff)
Now limit full scrape to requests sending exactly "GET /scrape HTTP/"
-rw-r--r--opentracker.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/opentracker.c b/opentracker.c
index 75f43f0..f2a7e84 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -379,6 +379,17 @@ LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: s24s old\n", h->ip[0], h->ip[1], h->i
379 /* We want the pure plain un-unescaped text */ 379 /* We want the pure plain un-unescaped text */
380 memmove( static_tmpbuf, static_inbuf, 8192 ); 380 memmove( static_tmpbuf, static_inbuf, 8192 );
381 381
382 /* Full scrape... you might want to limit that */
383 if( !byte_diff( data, 12, "scrape HTTP/" ) ) {
384
385LOG_TO_STDERR( "scrp: %d.%d.%d.%d - FULL SCRAPE\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] );
386write( 2, static_tmpbuf, l );
387
388 if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500;
389 ot_overall_tcp_successfulannounces++;
390 return sendmmapdata( s, reply, reply_size );
391 }
392
382 /* This is to hack around stupid clients that just replace 393 /* This is to hack around stupid clients that just replace
383 "announce ?info_hash" with "scrape ?info_hash". 394 "announce ?info_hash" with "scrape ?info_hash".
384 We do not want to bomb them with full scrapes */ 395 We do not want to bomb them with full scrapes */
@@ -406,15 +417,8 @@ SCRAPE_WORKAROUND:
406 } 417 }
407 } 418 }
408 419
409 /* Scanned whole query string, no hash means full scrape... you might want to limit that */ 420 /* No info_hash found? Inform user */
410 if( !scrape_count ) { 421 if( !scrape_count ) HTTPERROR_400_PARAM;
411LOG_TO_STDERR( "scrp: %d.%d.%d.%d - FULL SCRAPE\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] );
412write( 2, static_tmpbuf, l );
413write( 2, "\n\n\n", 1 );
414 if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500;
415 ot_overall_tcp_successfulannounces++;
416 return sendmmapdata( s, reply, reply_size );
417 }
418 422
419 /* Enough for http header + whole scrape string */ 423 /* Enough for http header + whole scrape string */
420 if( !( reply_size = return_tcp_scrape_for_torrent( multiscrape_buf, scrape_count, SUCCESS_HTTP_HEADER_LENGTH + static_outbuf ) ) ) HTTPERROR_500; 424 if( !( reply_size = return_tcp_scrape_for_torrent( multiscrape_buf, scrape_count, SUCCESS_HTTP_HEADER_LENGTH + static_outbuf ) ) ) HTTPERROR_500;