1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 08:43:27 +00:00

Show peers found and used when adding new peers.

Accept --without-foo in addition to --disable-foo in the configure script.
This commit is contained in:
Josh Elsasser 2007-03-29 00:19:09 +00:00
parent de3dc82ab2
commit 367426b51b
6 changed files with 42 additions and 25 deletions

4
configure vendored
View file

@ -219,10 +219,10 @@ while [ $# -ne 0 ]; do
param=`expr "opt$1" : 'opt[^=]*=\(.*\)'`
case "x$1" in
x--disable-openssl)
x--disable-openssl|x--without-openssl)
OPENSSL=no
;;
x--disable-gtk)
x--disable-gtk|x--without-gtk)
GTK=no
;;
x--prefix=*)

View file

@ -379,6 +379,7 @@ static int fastResumeLoad( tr_io_t * io )
case FR_ID_PEERS:
if( !( TR_FLAG_PRIVATE & tor->info.flags ) )
{
int used;
uint8_t * buf = malloc( len );
if( 1 != fread( buf, len, 1, file ) )
{
@ -386,8 +387,10 @@ static int fastResumeLoad( tr_io_t * io )
fclose( file );
return 1;
}
tr_torrentAddCompact( tor, TR_PEER_FROM_CACHE,
buf, len / 6 );
used = tr_torrentAddCompact( tor, TR_PEER_FROM_CACHE,
buf, len / 6 );
tr_dbg( "found %i peers in resume file, used %i",
len / 6, used );
free( buf );
}
continue;

View file

@ -146,9 +146,9 @@ typedef enum { TR_NET_OK, TR_NET_ERROR, TR_NET_WAIT } tr_tristate_t;
#include "http.h"
#include "xml.h"
void tr_torrentAddCompact( tr_torrent_t * tor, int from,
int tr_torrentAddCompact( tr_torrent_t * tor, int from,
uint8_t * buf, int count );
void tr_torrentAttachPeer( tr_torrent_t * tor, tr_peer_t * peer );
int tr_torrentAttachPeer( tr_torrent_t * tor, tr_peer_t * peer );
struct tr_torrent_s
{

View file

@ -444,7 +444,7 @@ parseAZPex( tr_torrent_t * tor, tr_peer_t * peer, uint8_t * buf, int len )
{
tr_info_t * info = &tor->info;
benc_val_t val, * list, * pair;
int ii;
int ii, used;
if( peer->private || PEX_PEER_CUTOFF <= tor->peerCount )
{
@ -483,18 +483,20 @@ parseAZPex( tr_torrent_t * tor, tr_peer_t * peer, uint8_t * buf, int len )
return TR_OK;
}
peer_dbg( "GET azureus-pex, %i peers", list->val.l.count );
used = 0;
for( ii = 0; ii < list->val.l.count; ii++ )
{
pair = &list->val.l.vals[ii];
if( TYPE_STR == pair->type && 6 == pair->val.s.i )
{
tr_torrentAddCompact( tor, TR_PEER_FROM_PEX,
( uint8_t * )pair->val.s.s, 1 );
used += tr_torrentAddCompact( tor, TR_PEER_FROM_PEX,
( uint8_t * )pair->val.s.s, 1 );
}
}
peer_dbg( "GET azureus-pex, found %i peers, using %i",
list->val.l.count, used );
tr_bencFree( &val );
return TR_OK;

View file

@ -267,6 +267,7 @@ static inline int
parseUTPex( tr_torrent_t * tor, tr_peer_t * peer, uint8_t * buf, int len )
{
benc_val_t val, * sub;
int used;
if( peer->private || PEX_PEER_CUTOFF <= tor->peerCount )
{
@ -290,9 +291,11 @@ parseUTPex( tr_torrent_t * tor, tr_peer_t * peer, uint8_t * buf, int len )
sub = tr_bencDictFind( &val, "added" );
if( NULL != sub && TYPE_STR == sub->type && 0 == sub->val.s.i % 6 )
{
peer_dbg( "GET extended-pex, %i peers", sub->val.s.i / 6 );
tr_torrentAddCompact( tor, TR_PEER_FROM_PEX,
( uint8_t * )sub->val.s.s, sub->val.s.i / 6 );
used = tr_torrentAddCompact( tor, TR_PEER_FROM_PEX,
( uint8_t * )sub->val.s.s,
sub->val.s.i / 6 );
peer_dbg( "GET extended-pex, got %i peers, used %i",
sub->val.s.i / 6, used );
}
else
{

View file

@ -282,7 +282,7 @@ int tr_getFinished( tr_torrent_t * tor )
void tr_manualUpdate( tr_torrent_t * tor )
{
int peerCount;
int peerCount, new;
uint8_t * peerCompact;
if( !( tor->status & TR_STATUS_ACTIVE ) )
@ -290,12 +290,14 @@ void tr_manualUpdate( tr_torrent_t * tor )
tr_lockLock( &tor->lock );
tr_trackerAnnouncePulse( tor->tracker, &peerCount, &peerCompact, 1 );
new = 0;
if( peerCount > 0 )
{
tr_torrentAddCompact( tor, TR_PEER_FROM_TRACKER,
new = tr_torrentAddCompact( tor, TR_PEER_FROM_TRACKER,
peerCompact, peerCount );
free( peerCompact );
}
tr_dbg( "got %i peers from manual announce, used %i", peerCount, new );
tr_lockUnlock( &tor->lock );
}
@ -613,7 +615,7 @@ void tr_torrentClose( tr_handle_t * h, tr_torrent_t * tor )
tr_sharedUnlock( h->shared );
}
void tr_torrentAttachPeer( tr_torrent_t * tor, tr_peer_t * peer )
int tr_torrentAttachPeer( tr_torrent_t * tor, tr_peer_t * peer )
{
int i;
tr_peer_t * otherPeer;
@ -621,7 +623,7 @@ void tr_torrentAttachPeer( tr_torrent_t * tor, tr_peer_t * peer )
if( tor->peerCount >= TR_MAX_PEER_COUNT )
{
tr_peerDestroy( peer );
return;
return 0;
}
/* Don't accept two connections from the same IP */
@ -631,31 +633,36 @@ void tr_torrentAttachPeer( tr_torrent_t * tor, tr_peer_t * peer )
if( !memcmp( tr_peerAddress( peer ), tr_peerAddress( otherPeer ), 4 ) )
{
tr_peerDestroy( peer );
return;
return 0;
}
}
tr_peerSetPrivate( peer, tor->info.flags & TR_FLAG_PRIVATE );
tr_peerSetTorrent( peer, tor );
tor->peers[tor->peerCount++] = peer;
return 1;
}
void tr_torrentAddCompact( tr_torrent_t * tor, int from,
int tr_torrentAddCompact( tr_torrent_t * tor, int from,
uint8_t * buf, int count )
{
struct in_addr addr;
in_port_t port;
int i;
int i, added;
tr_peer_t * peer;
added = 0;
for( i = 0; i < count; i++ )
{
memcpy( &addr, buf, 4 ); buf += 4;
memcpy( &port, buf, 2 ); buf += 2;
peer = tr_peerInit( addr, port, -1, from );
tr_torrentAttachPeer( tor, peer );
added += tr_torrentAttachPeer( tor, peer );
}
return added;
}
/***********************************************************************
@ -665,7 +672,7 @@ static void downloadLoop( void * _tor )
{
tr_torrent_t * tor = _tor;
int i, ret;
int peerCount;
int peerCount, used;
uint8_t * peerCompact;
tr_peer_t * peer;
@ -695,12 +702,14 @@ static void downloadLoop( void * _tor )
/* Try to get new peers or to send a message to the tracker */
tr_trackerPulse( tor->tracker, &peerCount, &peerCompact );
used = 0;
if( peerCount > 0 )
{
tr_torrentAddCompact( tor, TR_PEER_FROM_TRACKER,
peerCompact, peerCount );
used = tr_torrentAddCompact( tor, TR_PEER_FROM_TRACKER,
peerCompact, peerCount );
free( peerCompact );
}
tr_dbg( "got %i peers from announce, used %i", peerCount, used );
if( tor->status & TR_STATUS_STOPPED )
{
break;