From 8d13a14584a50cb0f192456a6388c7299d67db43 Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Thu, 14 Dec 2006 02:54:08 +0000 Subject: [PATCH] announce now returns all mandatory answer dictionary entries --- opentracker.c | 2 +- trackerlogic.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/opentracker.c b/opentracker.c index 6858f37..35482e4 100644 --- a/opentracker.c +++ b/opentracker.c @@ -270,7 +270,7 @@ e500: httperror(h,"500 Internal Server Error","A server error has occured. Please retry later."); 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 ) reply_size = return_peers_for_torrent( torrent, numwant, reply ); if( !reply || ( reply_size < 0 ) ) { diff --git a/trackerlogic.c b/trackerlogic.c index 0207fad..7b5b94a 100644 --- a/trackerlogic.c +++ b/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 ) { 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 wert = -1; - for( peer_count=index=0; indexpeer_list->peers[index].size; + for( peer_count=seed_count=index=0; indexpeer_list->peers[index].size; + seed_count += torrent->peer_list->seed_count[index]; + } if( peer_count < amount ) amount = peer_count; 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 ); r += 6; } - *r++ = 'e'; + r += FORMAT_FORMAT_STRING( r, "8:completei%lie10:incompletei%lie8:intervali60ee", seed_count, peer_count-seed_count ); + return r - reply; }