diff options
| author | erdgeist <> | 2007-03-06 19:43:47 +0000 |
|---|---|---|
| committer | erdgeist <> | 2007-03-06 19:43:47 +0000 |
| commit | 0a9021668658a2db0f52a3bcb062c74bd318ac8b (patch) | |
| tree | 73557a3215698d702582295ec309a434a061993b /trackerlogic.c | |
| parent | 175c37c3e89f179a3da82a66b06b931b24a52b98 (diff) | |
udp is working in theory, return_peers_for_torrent accepts a switch to request an udp answer. Fixed prototypes.
Diffstat (limited to 'trackerlogic.c')
| -rw-r--r-- | trackerlogic.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/trackerlogic.c b/trackerlogic.c index 18e8cf5..a2cd1ab 100644 --- a/trackerlogic.c +++ b/trackerlogic.c | |||
| @@ -269,7 +269,7 @@ ot_torrent *add_peer_to_torrent( ot_hash *hash, ot_peer *peer ) { | |||
| 269 | * RANDOM may return huge values | 269 | * RANDOM may return huge values |
| 270 | * does not yet check not to return self | 270 | * does not yet check not to return self |
| 271 | */ | 271 | */ |
| 272 | size_t return_peers_for_torrent( ot_torrent *torrent, size_t amount, char *reply ) { | 272 | size_t return_peers_for_torrent( ot_torrent *torrent, size_t amount, char *reply, int is_tcp ) { |
| 273 | char *r = reply; | 273 | char *r = reply; |
| 274 | size_t peer_count, seed_count, index; | 274 | size_t peer_count, seed_count, index; |
| 275 | 275 | ||
| @@ -295,7 +295,15 @@ size_t return_peers_for_torrent( ot_torrent *torrent, size_t amount, char *reply | |||
| 295 | } | 295 | } |
| 296 | if( peer_count < amount ) amount = peer_count; | 296 | if( peer_count < amount ) amount = peer_count; |
| 297 | 297 | ||
| 298 | r += sprintf( r, "d8:completei%zde10:incompletei%zde8:intervali%ie5:peers%zd:", seed_count, peer_count-seed_count, OT_CLIENT_REQUEST_INTERVAL_RANDOM, 6*amount ); | 298 | if( is_tcp ) |
| 299 | r += sprintf( r, "d8:completei%zde10:incompletei%zde8:intervali%ie5:peers%zd:", seed_count, peer_count-seed_count, OT_CLIENT_REQUEST_INTERVAL_RANDOM, 6*amount ); | ||
| 300 | else { | ||
| 301 | *(unsigned long*)(r+0) = htonl( OT_CLIENT_REQUEST_INTERVAL_RANDOM ); | ||
| 302 | *(unsigned long*)(r+4) = htonl( peer_count ); | ||
| 303 | *(unsigned long*)(r+8) = htonl( seed_count ); | ||
| 304 | r += 12; | ||
| 305 | } | ||
| 306 | |||
| 299 | if( amount ) { | 307 | if( amount ) { |
| 300 | unsigned int pool_offset, pool_index = 0;; | 308 | unsigned int pool_offset, pool_index = 0;; |
| 301 | unsigned int shifted_pc = peer_count; | 309 | unsigned int shifted_pc = peer_count; |
| @@ -327,7 +335,8 @@ size_t return_peers_for_torrent( ot_torrent *torrent, size_t amount, char *reply | |||
| 327 | r += 6; | 335 | r += 6; |
| 328 | } | 336 | } |
| 329 | } | 337 | } |
| 330 | *r++ = 'e'; | 338 | if( is_tcp ) |
| 339 | *r++ = 'e'; | ||
| 331 | 340 | ||
| 332 | return r - reply; | 341 | return r - reply; |
| 333 | } | 342 | } |
