summaryrefslogtreecommitdiff
path: root/opentracker.c
diff options
context:
space:
mode:
Diffstat (limited to 'opentracker.c')
-rw-r--r--opentracker.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/opentracker.c b/opentracker.c
index caa1312..191d5d6 100644
--- a/opentracker.c
+++ b/opentracker.c
@@ -88,7 +88,7 @@ struct http_data {
88int main( int argc, char **argv ); 88int main( int argc, char **argv );
89 89
90static void httperror( const int64 s, const char *title, const char *message ); 90static void httperror( const int64 s, const char *title, const char *message );
91static void httpresponse( const int64 s, char *data ); 91static void httpresponse( const int64 s, char *data, size_t l );
92 92
93static void sendmmapdata( const int64 s, char *buffer, const size_t size ); 93static void sendmmapdata( const int64 s, char *buffer, const size_t size );
94static void senddata( const int64 s, char *buffer, const size_t size ); 94static void senddata( const int64 s, char *buffer, const size_t size );
@@ -210,7 +210,7 @@ static void senddata( const int64 s, char *buffer, size_t size ) {
210 } 210 }
211} 211}
212 212
213static void httpresponse( const int64 s, char *data ) { 213static void httpresponse( const int64 s, char *data, size_t l ) {
214 struct http_data* h = io_getcookie( s ); 214 struct http_data* h = io_getcookie( s );
215 char *c, *reply; 215 char *c, *reply;
216 ot_peer peer; 216 ot_peer peer;
@@ -395,7 +395,9 @@ SCRAPE_WORKAROUND:
395 /* Scanned whole query string, no hash means full scrape... you might want to limit that */ 395 /* Scanned whole query string, no hash means full scrape... you might want to limit that */
396 if( !hash ) { 396 if( !hash ) {
397LOG_TO_STDERR( "scrp: %d.%d.%d.%d - FULL SCRAPE\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); 397LOG_TO_STDERR( "scrp: %d.%d.%d.%d - FULL SCRAPE\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] );
398 398LOG_TO_STDERR( "GET /scrape" );
399write( 2, data, l-12 );
400write( 2, "\n", 1 );
399 if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500; 401 if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500;
400 ot_overall_tcp_successfulannounces++; 402 ot_overall_tcp_successfulannounces++;
401 return sendmmapdata( s, reply, reply_size ); 403 return sendmmapdata( s, reply, reply_size );
@@ -599,7 +601,7 @@ static void handle_read( const int64 clientsocket ) {
599 /* If we get the whole request in one packet, handle it without copying */ 601 /* If we get the whole request in one packet, handle it without copying */
600 if( !array_start( &h->request ) ) { 602 if( !array_start( &h->request ) ) {
601 if( memchr( static_inbuf, '\n', l ) ) 603 if( memchr( static_inbuf, '\n', l ) )
602 return httpresponse( clientsocket, static_inbuf ); 604 return httpresponse( clientsocket, static_inbuf, l );
603 h->flag |= STRUCT_HTTP_FLAG_ARRAY_USED; 605 h->flag |= STRUCT_HTTP_FLAG_ARRAY_USED;
604 return array_catb( &h->request, static_inbuf, l ); 606 return array_catb( &h->request, static_inbuf, l );
605 } 607 }
@@ -614,7 +616,7 @@ static void handle_read( const int64 clientsocket ) {
614 return httperror( clientsocket, "500 request too long", "You sent too much headers"); 616 return httperror( clientsocket, "500 request too long", "You sent too much headers");
615 617
616 if( memchr( array_start( &h->request ), '\n', array_length( &h->request, 1 ) ) ) 618 if( memchr( array_start( &h->request ), '\n', array_length( &h->request, 1 ) ) )
617 return httpresponse( clientsocket, array_start( &h->request ) ); 619 return httpresponse( clientsocket, array_start( &h->request ), array_length( &h->request, 1 ) );
618} 620}
619 621
620static void handle_write( const int64 clientsocket ) { 622static void handle_write( const int64 clientsocket ) {