diff options
author | erdgeist <> | 2007-10-21 05:36:10 +0000 |
---|---|---|
committer | erdgeist <> | 2007-10-21 05:36:10 +0000 |
commit | 6876e162429dda51c202e598c0b4c6faf50cb964 (patch) | |
tree | 37abeb27c39a8be6b7c4353bbd2eae983ea4ace6 | |
parent | 3aa286d9b84f1f5ccb76a08e60fbf26ed30339aa (diff) |
assume anything looking like GET /a to be an announce...
-rw-r--r-- | opentracker.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/opentracker.c b/opentracker.c index d4cfea4..5da9829 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -248,7 +248,7 @@ static void httpresponse( const int64 s, char *data, size_t l ) { | |||
248 | * S Y N C * | 248 | * S Y N C * |
249 | ******************************/ | 249 | ******************************/ |
250 | case 4: /* sync ? */ | 250 | case 4: /* sync ? */ |
251 | if( !byte_diff( data, 2, "an" ) ) goto ANNOUNCE_WORKAROUND; | 251 | if( *data == 'a' ) goto ANNOUNCE_WORKAROUND; |
252 | if( !byte_diff( data, 2, "sc" ) ) goto SCRAPE_WORKAROUND; | 252 | if( !byte_diff( data, 2, "sc" ) ) goto SCRAPE_WORKAROUND; |
253 | if( byte_diff( data, 4, "sync") ) HTTPERROR_404; | 253 | if( byte_diff( data, 4, "sync") ) HTTPERROR_404; |
254 | if( NOTBLESSED( h ) ) HTTPERROR_403_IP; | 254 | if( NOTBLESSED( h ) ) HTTPERROR_403_IP; |
@@ -290,7 +290,7 @@ LOG_TO_STDERR( "sync: %d.%d.%d.%d\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); | |||
290 | * S T A T S * | 290 | * S T A T S * |
291 | ******************************/ | 291 | ******************************/ |
292 | case 5: /* stats ? */ | 292 | case 5: /* stats ? */ |
293 | if( !byte_diff( data, 2, "an" ) ) goto ANNOUNCE_WORKAROUND; | 293 | if( *data == 'a' ) goto ANNOUNCE_WORKAROUND; |
294 | if( !byte_diff( data, 2, "sc" ) ) goto SCRAPE_WORKAROUND; | 294 | if( !byte_diff( data, 2, "sc" ) ) goto SCRAPE_WORKAROUND; |
295 | if( byte_diff(data,5,"stats")) HTTPERROR_404; | 295 | if( byte_diff(data,5,"stats")) HTTPERROR_404; |
296 | scanon = 1; | 296 | scanon = 1; |
@@ -380,7 +380,7 @@ LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: s24s old\n", h->ip[0], h->ip[1], h->i | |||
380 | * S C R A P E * | 380 | * S C R A P E * |
381 | ******************************/ | 381 | ******************************/ |
382 | case 6: /* scrape ? */ | 382 | case 6: /* scrape ? */ |
383 | if( !byte_diff( data, 2, "an" ) ) goto ANNOUNCE_WORKAROUND; | 383 | if( *data == 'a' ) goto ANNOUNCE_WORKAROUND; |
384 | if( byte_diff( data, 6, "scrape") ) HTTPERROR_404; | 384 | if( byte_diff( data, 6, "scrape") ) HTTPERROR_404; |
385 | 385 | ||
386 | /* Full scrape... you might want to limit that */ | 386 | /* Full scrape... you might want to limit that */ |
@@ -401,6 +401,7 @@ SCRAPE_WORKAROUND: | |||
401 | if( c[-1] != '?' ) { | 401 | if( c[-1] != '?' ) { |
402 | while( ( *c != '?' ) && ( *c != '\n' ) ) ++c; | 402 | while( ( *c != '?' ) && ( *c != '\n' ) ) ++c; |
403 | if( *c == '\n' ) HTTPERROR_400_PARAM; | 403 | if( *c == '\n' ) HTTPERROR_400_PARAM; |
404 | ++c; | ||
404 | } | 405 | } |
405 | 406 | ||
406 | scanon = 1; | 407 | scanon = 1; |
@@ -441,7 +442,7 @@ UTORRENT1600_WORKAROUND: | |||
441 | ******************************/ | 442 | ******************************/ |
442 | case 8: | 443 | case 8: |
443 | if( !byte_diff( data, 2, "sc" ) ) goto SCRAPE_WORKAROUND; | 444 | if( !byte_diff( data, 2, "sc" ) ) goto SCRAPE_WORKAROUND; |
444 | if( byte_diff( data, 8, "announce" ) ) HTTPERROR_404; | 445 | if( *data != 'a' ) HTTPERROR_404; |
445 | 446 | ||
446 | ANNOUNCE_WORKAROUND: | 447 | ANNOUNCE_WORKAROUND: |
447 | 448 | ||
@@ -449,6 +450,7 @@ ANNOUNCE_WORKAROUND: | |||
449 | if( c[-1] != '?' ) { | 450 | if( c[-1] != '?' ) { |
450 | while( ( *c != '?' ) && ( *c != '\n' ) ) ++c; | 451 | while( ( *c != '?' ) && ( *c != '\n' ) ) ++c; |
451 | if( *c == '\n' ) HTTPERROR_400_PARAM; | 452 | if( *c == '\n' ) HTTPERROR_400_PARAM; |
453 | ++c; | ||
452 | } | 454 | } |
453 | 455 | ||
454 | OT_SETIP( &peer, ((struct http_data*)io_getcookie( s ) )->ip ); | 456 | OT_SETIP( &peer, ((struct http_data*)io_getcookie( s ) )->ip ); |
@@ -538,7 +540,7 @@ ANNOUNCE_WORKAROUND: | |||
538 | ot_overall_tcp_successfulannounces++; | 540 | ot_overall_tcp_successfulannounces++; |
539 | break; | 541 | break; |
540 | case 11: | 542 | case 11: |
541 | if( !byte_diff( data, 2, "an" ) ) goto ANNOUNCE_WORKAROUND; | 543 | if( *data == 'a' ) goto ANNOUNCE_WORKAROUND; |
542 | if( !byte_diff( data, 2, "sc" ) ) goto SCRAPE_WORKAROUND; | 544 | if( !byte_diff( data, 2, "sc" ) ) goto SCRAPE_WORKAROUND; |
543 | if( byte_diff( data, 11, "mrtg_scrape" ) ) HTTPERROR_404; | 545 | if( byte_diff( data, 11, "mrtg_scrape" ) ) HTTPERROR_404; |
544 | 546 | ||
@@ -548,7 +550,7 @@ ANNOUNCE_WORKAROUND: | |||
548 | ot_overall_tcp_connections+ot_overall_udp_connections, ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces, (int)t, (int)(t / 3600), (ot_overall_tcp_connections+ot_overall_udp_connections) / ( (unsigned int)t ? (unsigned int)t : 1 ) ); | 550 | ot_overall_tcp_connections+ot_overall_udp_connections, ot_overall_tcp_successfulannounces+ot_overall_udp_successfulannounces, (int)t, (int)(t / 3600), (ot_overall_tcp_connections+ot_overall_udp_connections) / ( (unsigned int)t ? (unsigned int)t : 1 ) ); |
549 | break; | 551 | break; |
550 | default: | 552 | default: |
551 | if( !byte_diff( data, 2, "an" ) ) goto ANNOUNCE_WORKAROUND; | 553 | if( *data == 'a' ) goto ANNOUNCE_WORKAROUND; |
552 | if( !byte_diff( data, 2, "sc" ) ) goto SCRAPE_WORKAROUND; | 554 | if( !byte_diff( data, 2, "sc" ) ) goto SCRAPE_WORKAROUND; |
553 | HTTPERROR_404; | 555 | HTTPERROR_404; |
554 | } | 556 | } |