Changeset 1594
- Timestamp:
- Mar 26, 2007, 7:19:33 PM (16 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/fastresume.h
r1579 r1594 172 172 fastResumeWriteData( FR_ID_UPLOADED, &total, 8, 1, file ); 173 173 174 /* Write IPs and ports of connectable peers, if any */ 175 if( ( size = tr_peerGetConnectable( tor, &buf ) ) > 0 ) 176 { 177 fastResumeWriteData( FR_ID_PEERS, buf, size, 1, file ); 178 free( buf ); 174 if( !( TR_FLAG_PRIVATE & tor->info.flags ) ) 175 { 176 /* Write IPs and ports of connectable peers, if any */ 177 if( ( size = tr_peerGetConnectable( tor, &buf ) ) > 0 ) 178 { 179 fastResumeWriteData( FR_ID_PEERS, buf, size, 1, file ); 180 free( buf ); 181 } 179 182 } 180 183 … … 375 378 376 379 case FR_ID_PEERS: 377 { 378 uint8_t * buf = malloc( len ); 379 if( 1 != fread( buf, len, 1, file ) ) 380 if( !( TR_FLAG_PRIVATE & tor->info.flags ) ) 380 381 { 382 uint8_t * buf = malloc( len ); 383 if( 1 != fread( buf, len, 1, file ) ) 384 { 385 free( buf ); 386 fclose( file ); 387 return 1; 388 } 389 tr_torrentAddCompact( tor, TR_PEER_FROM_CACHE, 390 buf, len / 6 ); 381 391 free( buf ); 382 fclose( file );383 return 1;384 392 } 385 tr_torrentAddCompact( tor, TR_PEER_FROM_CACHE, buf, len / 6 );386 free( buf );387 393 continue; 388 }389 394 390 395 default: -
trunk/libtransmission/internal.h
r1579 r1594 202 202 uint64_t uploadedPrev; 203 203 204 uint8_t pexDisabled; 205 204 206 tr_stat_t stats[2]; 205 207 int statCur; -
trunk/libtransmission/peer.c
r1579 r1594 224 224 void tr_peerSetPrivate( tr_peer_t * peer, int private ) 225 225 { 226 if( peer->private == private ) 227 { 228 return; 229 } 230 226 231 peer->private = private; 232 233 if( !private ) 234 { 235 peer->lastPex = 0; 236 } 237 238 if( EXTENDED_HANDSHAKE == peer->extStatus ) 239 { 240 sendExtended( peer->tor, peer, EXTENDED_HANDSHAKE_ID ); 241 } 227 242 } 228 243 -
trunk/libtransmission/peeraz.h
r1579 r1594 152 152 continue; 153 153 } 154 /* XXX azureus sucks, we can't enable or disable pex after handshake */ 154 155 if( AZ_MSG_AZ_PEER_EXCHANGE == azmsgId( idx ) && peer->private ) 155 156 { -
trunk/libtransmission/peerext.h
r1579 r1594 128 128 /* create dict of supported extended messages */ 129 129 tr_bencInit( msgsval, TYPE_DICT ); 130 if( !peer->private ) 131 { 132 /* for public torrents advertise utorrent pex message */ 133 if( tr_bencDictAppendNofree( msgsval, "ut_pex", &pexval, NULL ) ) 134 { 135 tr_bencFree( &val ); 136 return NULL; 137 } 138 tr_bencInitInt( pexval, EXTENDED_PEX_ID ); 139 } 130 if( tr_bencDictAppendNofree( msgsval, "ut_pex", &pexval, NULL ) ) 131 { 132 tr_bencFree( &val ); 133 return NULL; 134 } 135 /* for public torrents advertise utorrent pex message */ 136 tr_bencInitInt( pexval, ( peer->private ? 0 : EXTENDED_PEX_ID ) ); 140 137 141 138 /* our listening port */ … … 233 230 { 234 231 peer->pexStatus = 0; 235 if( !peer->private &&0x0 < sub->val.i && 0xff >= sub->val.i )232 if( 0x0 < sub->val.i && 0xff >= sub->val.i ) 236 233 { 237 234 peer->pexStatus = sub->val.i; -
trunk/libtransmission/torrent.c
r1579 r1594 138 138 } 139 139 140 tor->pexDisabled = 0; 141 140 142 /* Block size: usually 16 ko, or less if we have to */ 141 143 tor->blockSize = MIN( inf->pieceSize, 1 << 14 ); … … 268 270 } 269 271 tor->peerCount = 0; 272 tr_lockUnlock( &tor->lock ); 273 } 274 275 void tr_torrentDisablePex( tr_torrent_t * tor, int disable ) 276 { 277 int ii; 278 279 if( TR_FLAG_PRIVATE & tor->info.flags ) 280 { 281 return; 282 } 283 284 tr_lockLock( &tor->lock ); 285 286 if( tor->pexDisabled == disable ) 287 { 288 tr_lockUnlock( &tor->lock ); 289 return; 290 } 291 292 tor->pexDisabled = disable; 293 for( ii = 0; ii < tor->peerCount; ii++ ) 294 { 295 tr_peerSetPrivate( tor->peers[ii], disable ); 296 } 297 270 298 tr_lockUnlock( &tor->lock ); 271 299 } … … 636 664 } 637 665 638 tr_peerSetPrivate( peer, tor->info.flags & TR_FLAG_PRIVATE ); 666 tr_peerSetPrivate( peer, tor->info.flags & TR_FLAG_PRIVATE || 667 tor->pexDisabled ); 639 668 tr_peerSetTorrent( peer, tor ); 640 669 tor->peers[tor->peerCount++] = peer; -
trunk/libtransmission/transmission.h
r1579 r1594 224 224 int flags, int * error ); 225 225 226 /*********************************************************************** 227 * tr_torrentDisablePex 228 *********************************************************************** 229 * Disable or enable peer exchange for this torrent. Peer exchange is 230 * enabled by default, except for private torrents where pex is 231 * disabled and cannot be enabled. 232 **********************************************************************/ 233 void tr_torrentDisablePex( tr_torrent_t *, int disable ); 234 235 /*********************************************************************** 236 * tr_torrentScrape 237 *********************************************************************** 238 * Return torrent metainfo. 239 **********************************************************************/ 226 240 typedef struct tr_info_s tr_info_t; 227 241 tr_info_t * tr_torrentInfo( tr_torrent_t * );
Note: See TracChangeset
for help on using the changeset viewer.