mirror of
				git://erdgeist.org/opentracker
				synced 2025-11-04 11:53:22 +08:00 
			
		
		
		
	announce now returns all mandatory answer dictionary entries
This commit is contained in:
		
							parent
							
								
									688a4edd9e
								
							
						
					
					
						commit
						8d13a14584
					
				@ -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 ) ) {
 | 
				
			||||||
 | 
				
			|||||||
@ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user