summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ot_fullscrape.c10
-rw-r--r--ot_livesync.c9
-rw-r--r--trackerlogic.c12
3 files changed, 17 insertions, 14 deletions
diff --git a/ot_fullscrape.c b/ot_fullscrape.c
index 523d883..58546ca 100644
--- a/ot_fullscrape.c
+++ b/ot_fullscrape.c
@@ -165,8 +165,7 @@ static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tas
165 165
166 /* push hash as bencoded string */ 166 /* push hash as bencoded string */
167 *r++='2'; *r++='0'; *r++=':'; 167 *r++='2'; *r++='0'; *r++=':';
168 for(i=0;i<20;i+=4) WRITE32(r+=4,0,READ32(hash,i)); 168 for(i=0;i<20;i+=4) WRITE32(r,i,READ32(hash,i)); r+=20;
169
170 /* push rest of the scrape string */ 169 /* push rest of the scrape string */
171 r += sprintf( r, "d8:completei%zde10:downloadedi%zde10:incompletei%zdee", peer_list->seed_count, peer_list->down_count, peer_list->peer_count-peer_list->seed_count ); 170 r += sprintf( r, "d8:completei%zde10:downloadedi%zde10:incompletei%zdee", peer_list->seed_count, peer_list->down_count, peer_list->peer_count-peer_list->seed_count );
172 171
@@ -176,9 +175,10 @@ static void fullscrape_make( int *iovec_entries, struct iovec **iovector, ot_tas
176 r += sprintf( r, ":%zd:%zd\n", peer_list->seed_count, peer_list->peer_count-peer_list->seed_count ); 175 r += sprintf( r, ":%zd:%zd\n", peer_list->seed_count, peer_list->peer_count-peer_list->seed_count );
177 break; 176 break;
178 case TASK_FULLSCRAPE_TPB_BINARY: 177 case TASK_FULLSCRAPE_TPB_BINARY:
179 for(i=0;i<20;i+=4) WRITE32(r+=4,0,READ32(hash,i)); 178 for(i=0;i<20;i+=4) WRITE32(r,i,READ32(hash,i)); r+=20;
180 *(uint32_t*)(r+=4) = htonl( (uint32_t) peer_list->seed_count ); 179 *(uint32_t*)(r+0) = htonl( (uint32_t) peer_list->seed_count );
181 *(uint32_t*)(r+=4) = htonl( (uint32_t)( peer_list->peer_count-peer_list->seed_count) ); 180 *(uint32_t*)(r+4) = htonl( (uint32_t)( peer_list->peer_count-peer_list->seed_count) );
181 r+=8;
182 break; 182 break;
183 case TASK_FULLSCRAPE_TPB_URLENCODED: 183 case TASK_FULLSCRAPE_TPB_URLENCODED:
184 r += fmt_urlencoded( r, (char *)*hash, 20 ); 184 r += fmt_urlencoded( r, (char *)*hash, 20 );
diff --git a/ot_livesync.c b/ot_livesync.c
index f61f0ec..3cad121 100644
--- a/ot_livesync.c
+++ b/ot_livesync.c
@@ -101,10 +101,11 @@ static void livesync_issuepacket( ) {
101/* Inform live sync about whats going on. */ 101/* Inform live sync about whats going on. */
102void livesync_tell( ot_hash * const info_hash, const ot_peer * const peer ) { 102void livesync_tell( ot_hash * const info_hash, const ot_peer * const peer ) {
103 int i; 103 int i;
104 for(i=0;i<20;i+=4) WRITE32(livesync_outbuffer_pos+=4,0,READ32(info_hash,i)); 104 for(i=0;i<20;i+=4) WRITE32(livesync_outbuffer_pos,i,READ32(info_hash,i));
105 WRITE32(livesync_outbuffer_pos+=4,0,READ32(peer,0)); 105 WRITE32(livesync_outbuffer_pos,20,READ32(peer,0));
106 WRITE32(livesync_outbuffer_pos+=4,0,READ32(peer,4)); 106 WRITE32(livesync_outbuffer_pos,24,READ32(peer,4));
107 107 livesync_outbuffer_pos += 28;
108
108 if( livesync_outbuffer_pos >= livesync_outbuffer_highwater ) 109 if( livesync_outbuffer_pos >= livesync_outbuffer_highwater )
109 livesync_issuepacket(); 110 livesync_issuepacket();
110} 111}
diff --git a/trackerlogic.c b/trackerlogic.c
index d6a7a33..7d6294d 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -164,8 +164,9 @@ static size_t return_peers_all( ot_peerlist *peer_list, char *reply ) {
164 ot_peer * peers = (ot_peer*)bucket_list[bucket].data; 164 ot_peer * peers = (ot_peer*)bucket_list[bucket].data;
165 size_t peer_count = bucket_list[bucket].size; 165 size_t peer_count = bucket_list[bucket].size;
166 while( peer_count-- ) { 166 while( peer_count-- ) {
167 WRITE32(r+=4,0,READ32(peers,0)); 167 WRITE32(r,0,READ32(peers,0));
168 WRITE16(r+=2,0,READ16(peers++,4)); 168 WRITE16(r,4,READ16(peers++,4));
169 r+=6;
169 } 170 }
170 } 171 }
171 172
@@ -208,8 +209,9 @@ static size_t return_peers_selection( ot_peerlist *peer_list, size_t amount, cha
208 bucket_index = ( bucket_index + 1 ) % num_buckets; 209 bucket_index = ( bucket_index + 1 ) % num_buckets;
209 } 210 }
210 peer = ((ot_peer*)bucket_list[bucket_index].data) + bucket_offset; 211 peer = ((ot_peer*)bucket_list[bucket_index].data) + bucket_offset;
211 WRITE32(r+=4,0,READ32(peer,0)); 212 WRITE32(r,0,READ32(peer,0));
212 WRITE16(r+=2,0,READ16(peer,4)); 213 WRITE16(r,4,READ16(peer,4));
214 r+=6;
213 } 215 }
214 return r - reply; 216 return r - reply;
215} 217}
@@ -294,7 +296,7 @@ size_t return_tcp_scrape_for_torrent( ot_hash *hash_list, int amount, char *repl
294 } else { 296 } else {
295 int j; 297 int j;
296 *r++='2';*r++='0';*r++=':'; 298 *r++='2';*r++='0';*r++=':';
297 for(j=0;j<20;j+=4) WRITE32(r+=4,0,READ32(hash,j)); 299 for(j=0;j<20;j+=4) WRITE32(r,j,READ32(hash,j)); r += 20;
298 r += sprintf( r, "d8:completei%zde10:downloadedi%zde10:incompletei%zdee", 300 r += sprintf( r, "d8:completei%zde10:downloadedi%zde10:incompletei%zdee",
299 torrent->peer_list->seed_count, torrent->peer_list->down_count, torrent->peer_list->peer_count-torrent->peer_list->seed_count ); 301 torrent->peer_list->seed_count, torrent->peer_list->down_count, torrent->peer_list->peer_count-torrent->peer_list->seed_count );
300 } 302 }