Browse Source

account downloaded before early returns

master
Dirk Engling 15 years ago
parent
commit
342e3a25c0
  1. 6
      README
  2. 6
      README_v6
  3. 4
      opentracker.c
  4. 2
      scan_urlencoded_query.c
  5. 2
      scan_urlencoded_query.h
  6. 11
      trackerlogic.c
  7. 4
      trackerlogic.h

6
README

@ -15,9 +15,9 @@ cd opentracker-1.0
make
./opentracker
This tracker is open in a sense that everyone announcing a torrent is welcome to do so and will be informed about anyone else announcing the same torrent. Unless
-DWANT_IP_FROM_QUERY_STRING is enabled (which is meant for debugging purposes only), only source IPs are accepted. The tracker implements a minimal set of
essential features only but was able respond to far more than 10000 requests per second on a Sun Fire 2200 M2 (thats where we found no more clients able to fire
This tracker is open in a sense that everyone announcing a torrent is welcome to do so and will be informed about anyone else announcing the same torrent. Unless
-DWANT_IP_FROM_QUERY_STRING is enabled (which is meant for debugging purposes only), only source IPs are accepted. The tracker implements a minimal set of
essential features only but was able respond to far more than 10000 requests per second on a Sun Fire 2200 M2 (thats where we found no more clients able to fire
more of our testsuite.sh script).
Some tweaks you may want to try under FreeBSD:

6
README_v6

@ -1,8 +1,8 @@
Q: Why is there no v6-support in opentracker?
A: Although I tried very hard, implementing v6 right now would be a terrible waste of bandwidth, there is no compact format for v6 addresses, so instead of
answering "d5:peers6:AAAAPPe" I'd have to send "d5:peersld2:ip39:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA4:port2:PPPPeee" for a single peer. Even if there was a
A: Although I tried very hard, implementing v6 right now would be a terrible waste of bandwidth, there is no compact format for v6 addresses, so instead of
answering "d5:peers6:AAAAPPe" I'd have to send "d5:peersld2:ip39:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA4:port2:PPPPeee" for a single peer. Even if there was a
compact mode, v6 addresses still would eat up thrice the memory, v4 addresses take. This, however, wouldn't be a show stopper.
Other problems concern efficient peer selection for obviously v6-capable peers and how to select peers for non-v6 clients. v6 addresses eat up more memory on the
Other problems concern efficient peer selection for obviously v6-capable peers and how to select peers for non-v6 clients. v6 addresses eat up more memory on the
host, too ;)

4
opentracker.c

@ -285,7 +285,7 @@ SCRAPE_WORKAROUND:
/* Enough for http header + whole scrape string */
if( ( reply_size = return_scrape_for_torrent( hash, SUCCESS_HTTP_HEADER_LENGTH + static_scratch ) ) <= 0 ) HTTPERROR_500;
break;
case 8:
case 8:
if( byte_diff(data,8,"announce")) HTTPERROR_404;
ANNOUNCE_WORKAROUND:
@ -383,7 +383,7 @@ ANNOUNCE_WORKAROUND:
if( byte_diff(data,11,"mrtg_scrape")) HTTPERROR_404;
t = time( NULL ) - ot_start_time;
reply_size = sprintf( static_scratch + SUCCESS_HTTP_HEADER_LENGTH,
reply_size = sprintf( static_scratch + SUCCESS_HTTP_HEADER_LENGTH,
"%i\n%i\nUp: %i seconds (%i hours)\nPretuned by german engineers, currently handling %i connections per second.",
ot_overall_connections, ot_overall_successfulannounces, (int)t, (int)(t / 3600), (int)ot_overall_connections / ( (int)t ? (int)t : 1 ) );
break;

2
scan_urlencoded_query.c

@ -1,4 +1,4 @@
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever. */
#include "scan.h"

2
scan_urlencoded_query.h

@ -1,4 +1,4 @@
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever. */
#ifndef __SCAN_URLENCODED_QUERY_H__

11
trackerlogic.c

@ -195,6 +195,9 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ) {
peer_pool = &torrent->peer_list->peers[0];
peer_dest = vector_find_or_insert( peer_pool, (void*)peer, sizeof( ot_peer ), OT_PEER_COMPARE_SIZE, &exactmatch );
if( OT_FLAG(peer) & PEER_FLAG_COMPLETED )
torrent->peer_list->downloaded++;
/* If we hadn't had a match in current pool, create peer there and
remove it from all older pools */
if( !exactmatch ) {
@ -215,8 +218,6 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ) {
if( !(OT_FLAG(peer_dest) & PEER_FLAG_SEEDING ) && (OT_FLAG(peer) & PEER_FLAG_SEEDING ) )
torrent->peer_list->seed_count[0]++;
}
if( OT_FLAG(peer) & PEER_FLAG_COMPLETED )
torrent->peer_list->downloaded++;
return torrent;
}
@ -435,13 +436,13 @@ void remove_peer_from_torrent( ot_hash *hash, ot_peer *peer ) {
int exactmatch, i;
ot_vector *torrents_list = &all_torrents[*hash[0]];
ot_torrent *torrent = binary_search( hash, torrents_list->data, torrents_list->size, sizeof( ot_torrent ), OT_HASH_COMPARE_SIZE, &exactmatch );
if( !exactmatch ) return;
/* Maybe this does the job */
if( clean_peerlist( NOW, torrent->peer_list ) ) {
#ifdef WANT_CLOSED_TRACKER
if( !g_closedtracker )
if( !g_closedtracker )
#endif
vector_remove_torrent( torrents_list, hash );
return;

4
trackerlogic.h

@ -1,4 +1,4 @@
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
It is considered beerware. Prost. Skol. Cheers or whatever. */
#ifndef __TRACKERLOGIC_H__
@ -44,7 +44,7 @@ typedef time_t ot_time;
typedef struct {
void *data;
size_t size;
size_t space;
size_t space;
} ot_vector;
typedef struct {

Loading…
Cancel
Save