summaryrefslogtreecommitdiff
path: root/trackerlogic.c
diff options
context:
space:
mode:
Diffstat (limited to 'trackerlogic.c')
-rw-r--r--trackerlogic.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/trackerlogic.c b/trackerlogic.c
index ee8596c..4c6b5b0 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -113,8 +113,8 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer WANT_SYNC_PARAM(
113 uint8_t *_ip = (uint8_t*)peer_dest; 113 uint8_t *_ip = (uint8_t*)peer_dest;
114 int i; 114 int i;
115 for( i=0;i<20;++i)printf("%02X",(*hash)[i]); 115 for( i=0;i<20;++i)printf("%02X",(*hash)[i]);
116 if( g_this_peerid_len ) g_this_peerid_data[g_this_peerid_len] = 0; 116 if( g_this_peerid_data ) g_this_peerid_data[g_this_peerid_len] = 0;
117 printf( " %d.%d.%d.%d:%d\t%d %02X %s\n", _ip[0], _ip[1], _ip[2], _ip[3], OT_PEERTIME( peer_dest ), OT_PEERTIME( peer_dest ), OT_FLAG(peer_dest), g_this_peerid_data ? g_this_peerid_data : "-" ); 117 printf( " %d.%d.%d.%d:%d\t%d %02X %s\n", _ip[0], _ip[1], _ip[2], _ip[3], OT_PEERTIME( peer_dest ), *(uint16_t*)( ((char*)peer_dest)+4 ), OT_FLAG(peer_dest), g_this_peerid_data ? g_this_peerid_data : "-" );
118 } 118 }
119#endif 119#endif
120 120
@@ -224,9 +224,10 @@ size_t return_peers_for_torrent( ot_torrent *torrent, size_t amount, char *reply
224 if( amount > peer_list->peer_count ) 224 if( amount > peer_list->peer_count )
225 amount = peer_list->peer_count; 225 amount = peer_list->peer_count;
226 226
227 if( proto == FLAG_TCP ) 227 if( proto == FLAG_TCP ) {
228 r += sprintf( r, "d8:completei%zde10:downloadedi%zde10:incompletei%zde8:intervali%ie5:peers%zd:", peer_list->seed_count, peer_list->down_count, peer_list->peer_count-peer_list->seed_count, OT_CLIENT_REQUEST_INTERVAL_RANDOM, 6*amount ); 228 int erval = OT_CLIENT_REQUEST_INTERVAL_RANDOM;
229 else { 229 r += sprintf( r, "d8:completei%zde10:downloadedi%zde10:incompletei%zde8:intervali%ie12:min intervali%ie5:peers%zd:", peer_list->seed_count, peer_list->down_count, peer_list->peer_count-peer_list->seed_count, erval, erval/2, 6*amount );
230 } else {
230 *(uint32_t*)(r+0) = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM ); 231 *(uint32_t*)(r+0) = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM );
231 *(uint32_t*)(r+4) = htonl( peer_list->peer_count ); 232 *(uint32_t*)(r+4) = htonl( peer_list->peer_count );
232 *(uint32_t*)(r+8) = htonl( peer_list->seed_count ); 233 *(uint32_t*)(r+8) = htonl( peer_list->seed_count );
@@ -323,9 +324,11 @@ size_t remove_peer_from_torrent( ot_hash *hash, ot_peer *peer, char *reply, PROT
323 } 324 }
324 } 325 }
325 326
326 if( proto == FLAG_TCP ) 327 if( proto == FLAG_TCP ) {
327 reply_size = sprintf( reply, "d8:completei%zde10:incompletei%zde8:intervali%ie5:peers0:e", peer_list->seed_count, peer_list->peer_count - peer_list->seed_count, OT_CLIENT_REQUEST_INTERVAL_RANDOM ); 328 int erval = OT_CLIENT_REQUEST_INTERVAL_RANDOM;
328 329 reply_size = sprintf( reply, "d8:completei%zde10:incompletei%zde8:intervali%ie12min intervali%ie5:peers0:e", peer_list->seed_count, peer_list->peer_count - peer_list->seed_count, erval, erval / 2 );
330 }
331
329 /* Handle UDP reply */ 332 /* Handle UDP reply */
330 if( proto == FLAG_UDP ) { 333 if( proto == FLAG_UDP ) {
331 ((uint32_t*)reply)[2] = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM ); 334 ((uint32_t*)reply)[2] = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM );