Browse Source

announce now returns all mandatory answer dictionary entries

dynamic-accesslists
erdgeist 18 years ago
parent
commit
8d13a14584
  1. 2
      opentracker.c
  2. 10
      trackerlogic.c

2
opentracker.c

@ -270,7 +270,7 @@ e500:
httperror(h,"500 Internal Server Error","A server error has occured. Please retry later."); httperror(h,"500 Internal Server Error","A server error has occured. Please retry later.");
goto bailout; goto bailout;
} }
reply = malloc( numwant*6+64 ); // peerlist + seeder, peers and lametta reply = malloc( numwant*6+128 ); // peerlist + seeder, peers and lametta n*6+81 a.t.m.
if( reply ) if( reply )
reply_size = return_peers_for_torrent( torrent, numwant, reply ); reply_size = return_peers_for_torrent( torrent, numwant, reply );
if( !reply || ( reply_size < 0 ) ) { if( !reply || ( reply_size < 0 ) ) {

10
trackerlogic.c

@ -193,11 +193,14 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ) {
// //
size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char *reply ) { size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char *reply ) {
char *r = reply; char *r = reply;
unsigned long peer_count, index; unsigned long peer_count, seed_count, index;
signed long pool_offset = -1, pool_index = 0; signed long pool_offset = -1, pool_index = 0;
signed long wert = -1; signed long wert = -1;
for( peer_count=index=0; index<OT_POOLS_COUNT; ++index) peer_count += torrent->peer_list->peers[index].size; for( peer_count=seed_count=index=0; index<OT_POOLS_COUNT; ++index) {
peer_count += torrent->peer_list->peers[index].size;
seed_count += torrent->peer_list->seed_count[index];
}
if( peer_count < amount ) amount = peer_count; if( peer_count < amount ) amount = peer_count;
r += FORMAT_FORMAT_STRING( r, "d5:peers%li:",6*amount ); r += FORMAT_FORMAT_STRING( r, "d5:peers%li:",6*amount );
@ -215,7 +218,8 @@ size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char
MEMMOVE( r, ((ot_peer*)torrent->peer_list->peers[pool_index].data) + pool_offset, 6 ); MEMMOVE( r, ((ot_peer*)torrent->peer_list->peers[pool_index].data) + pool_offset, 6 );
r += 6; r += 6;
} }
*r++ = 'e'; r += FORMAT_FORMAT_STRING( r, "8:completei%lie10:incompletei%lie8:intervali60ee", seed_count, peer_count-seed_count );
return r - reply; return r - reply;
} }

Loading…
Cancel
Save