summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--opentracker.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/opentracker.c b/opentracker.c
index 1725cd2..81f5daa 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -59,6 +59,7 @@ static char *accesslist_filename = NULL;
59 59
60static char static_inbuf[8192]; 60static char static_inbuf[8192];
61static char static_outbuf[8192]; 61static char static_outbuf[8192];
62static char static_tmpbuf[8192];
62 63
63static char *FLAG_TCP = "TCP"; 64static char *FLAG_TCP = "TCP";
64static char *FLAG_UDP = "UDP"; 65static char *FLAG_UDP = "UDP";
@@ -372,6 +373,9 @@ LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: s24s old\n", h->ip[0], h->ip[1], h->i
372 case 6: /* scrape ? */ 373 case 6: /* scrape ? */
373 if( byte_diff( data, 6, "scrape") ) HTTPERROR_404; 374 if( byte_diff( data, 6, "scrape") ) HTTPERROR_404;
374 375
376 /* We want the pure plain un-unescaped text */
377 memmove( static_tmpbuf, static_inbuf, 8192 );
378
375 /* This is to hack around stupid clients that just replace 379 /* This is to hack around stupid clients that just replace
376 "announce ?info_hash" with "scrape ?info_hash". 380 "announce ?info_hash" with "scrape ?info_hash".
377 We do not want to bomb them with full scrapes */ 381 We do not want to bomb them with full scrapes */
@@ -400,9 +404,8 @@ SCRAPE_WORKAROUND:
400 /* Scanned whole query string, no hash means full scrape... you might want to limit that */ 404 /* Scanned whole query string, no hash means full scrape... you might want to limit that */
401 if( !hash ) { 405 if( !hash ) {
402LOG_TO_STDERR( "scrp: %d.%d.%d.%d - FULL SCRAPE\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); 406LOG_TO_STDERR( "scrp: %d.%d.%d.%d - FULL SCRAPE\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] );
403LOG_TO_STDERR( "GET /scrape" ); 407write( 2, static_tmpbuf, l );
404write( 2, data, l-12 ); 408write( 2, "\n\n\n", 1 );
405write( 2, "\n", 1 );
406 if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500; 409 if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500;
407 ot_overall_tcp_successfulannounces++; 410 ot_overall_tcp_successfulannounces++;
408 return sendmmapdata( s, reply, reply_size ); 411 return sendmmapdata( s, reply, reply_size );
@@ -623,8 +626,8 @@ static void handle_read( const int64 clientsocket ) {
623 if( ( array_bytes( &h->request ) > 8192 ) && NOTBLESSED( h ) ) 626 if( ( array_bytes( &h->request ) > 8192 ) && NOTBLESSED( h ) )
624 return httperror( clientsocket, "500 request too long", "You sent too much headers"); 627 return httperror( clientsocket, "500 request too long", "You sent too much headers");
625 628
626 if( memchr( array_start( &h->request ), '\n', array_length( &h->request, 1 ) ) ) 629 if( memchr( array_start( &h->request ), '\n', array_bytes( &h->request ) ) )
627 return httpresponse( clientsocket, array_start( &h->request ), array_length( &h->request, 1 ) ); 630 return httpresponse( clientsocket, array_start( &h->request ), array_bytes( &h->request ) );
628} 631}
629 632
630static void handle_write( const int64 clientsocket ) { 633static void handle_write( const int64 clientsocket ) {