diff options
author | erdgeist <> | 2006-12-14 02:54:08 +0000 |
---|---|---|
committer | erdgeist <> | 2006-12-14 02:54:08 +0000 |
commit | 8d13a14584a50cb0f192456a6388c7299d67db43 (patch) | |
tree | 3a9c7960975c5603504564815e0fbf80bd5561bd | |
parent | 688a4edd9e489de26a9b53ea79f513e6461c7533 (diff) |
announce now returns all mandatory answer dictionary entries
-rw-r--r-- | opentracker.c | 2 | ||||
-rw-r--r-- | 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: | |||
270 | httperror(h,"500 Internal Server Error","A server error has occured. Please retry later."); | 270 | httperror(h,"500 Internal Server Error","A server error has occured. Please retry later."); |
271 | goto bailout; | 271 | goto bailout; |
272 | } | 272 | } |
273 | reply = malloc( numwant*6+64 ); // peerlist + seeder, peers and lametta | 273 | reply = malloc( numwant*6+128 ); // peerlist + seeder, peers and lametta n*6+81 a.t.m. |
274 | if( reply ) | 274 | if( reply ) |
275 | reply_size = return_peers_for_torrent( torrent, numwant, reply ); | 275 | reply_size = return_peers_for_torrent( torrent, numwant, reply ); |
276 | if( !reply || ( reply_size < 0 ) ) { | 276 | 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 ) { | |||
193 | // | 193 | // |
194 | size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char *reply ) { | 194 | size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char *reply ) { |
195 | char *r = reply; | 195 | char *r = reply; |
196 | unsigned long peer_count, index; | 196 | unsigned long peer_count, seed_count, index; |
197 | signed long pool_offset = -1, pool_index = 0; | 197 | signed long pool_offset = -1, pool_index = 0; |
198 | signed long wert = -1; | 198 | signed long wert = -1; |
199 | 199 | ||
200 | for( peer_count=index=0; index<OT_POOLS_COUNT; ++index) peer_count += torrent->peer_list->peers[index].size; | 200 | for( peer_count=seed_count=index=0; index<OT_POOLS_COUNT; ++index) { |
201 | peer_count += torrent->peer_list->peers[index].size; | ||
202 | seed_count += torrent->peer_list->seed_count[index]; | ||
203 | } | ||
201 | if( peer_count < amount ) amount = peer_count; | 204 | if( peer_count < amount ) amount = peer_count; |
202 | 205 | ||
203 | r += FORMAT_FORMAT_STRING( r, "d5:peers%li:",6*amount ); | 206 | 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 | |||
215 | MEMMOVE( r, ((ot_peer*)torrent->peer_list->peers[pool_index].data) + pool_offset, 6 ); | 218 | MEMMOVE( r, ((ot_peer*)torrent->peer_list->peers[pool_index].data) + pool_offset, 6 ); |
216 | r += 6; | 219 | r += 6; |
217 | } | 220 | } |
218 | *r++ = 'e'; | 221 | r += FORMAT_FORMAT_STRING( r, "8:completei%lie10:incompletei%lie8:intervali60ee", seed_count, peer_count-seed_count ); |
222 | |||
219 | return r - reply; | 223 | return r - reply; |
220 | } | 224 | } |
221 | 225 | ||