add some debugging stuff to track down where some bogus addresses are coming from
This commit is contained in:
parent
2b0ece7614
commit
38efb62100
|
@ -68,6 +68,36 @@ tr_netInit( void )
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
tr_suspectAddress( const tr_address * a, const char * source )
|
||||
{
|
||||
/* be really aggressive in what we report */
|
||||
if( a->type == TR_AF_INET && !( a->addr.addr4.s_addr & 0xff000000 ) )
|
||||
tr_dbg( "Funny looking address %s from %s", tr_ntop_non_ts( a ), source );
|
||||
/* /16s taken from ipv6 rib on 21 dec, 2008 */
|
||||
/* this is really, really ugly. expedience over quality */
|
||||
if( a->type == TR_AF_INET6 )
|
||||
{
|
||||
uint16_t slash16;
|
||||
uint16_t valid[] = { 0x339, 0x2002, 0x2003, 0x2400, 0x2401, 0x2402,
|
||||
0x2403, 0x2404, 0x2405, 0x2406, 0x2407, 0x2600, 0x2607, 0x2610,
|
||||
0x2620, 0x2800, 0x2801, 0x2a00, 0x2a01, 0x0a02, 0x2001, 0x0000 };
|
||||
uint16_t *p;
|
||||
tr_bool good = FALSE;
|
||||
p = valid;
|
||||
memcpy( &slash16, &a->addr, 2 );
|
||||
slash16 = ntohs( slash16 );
|
||||
while( *p )
|
||||
{
|
||||
if( slash16 == *p )
|
||||
good = TRUE;
|
||||
p++;
|
||||
}
|
||||
if( !good )
|
||||
tr_dbg( "Funny looking address %s from %s", tr_ntop_non_ts( a ), source );
|
||||
}
|
||||
}
|
||||
|
||||
tr_bool
|
||||
tr_isAddress( const tr_address * a )
|
||||
{
|
||||
|
|
|
@ -85,6 +85,7 @@ int tr_compareAddresses( const tr_address * a,
|
|||
const tr_address * b);
|
||||
void tr_normalizeV4Mapped( tr_address * const addr );
|
||||
|
||||
void tr_suspectAddress( const tr_address * a, const char * source );
|
||||
tr_bool tr_isAddress( const tr_address * a );
|
||||
|
||||
typedef struct tr_net_af_support
|
||||
|
|
|
@ -1432,6 +1432,7 @@ tr_peerMgrArrayToPex( const void * array,
|
|||
|
||||
for( i = 0 ; i < n ; i++ ) {
|
||||
memcpy( &pex[i].addr, walk, sizeof( tr_address ) );
|
||||
tr_suspectAddress( &pex[i].addr, "tracker" );
|
||||
memcpy( &pex[i].port, walk + sizeof( tr_address ), 2 );
|
||||
pex[i].flags = 0x00;
|
||||
walk += sizeof( tr_address ) + 2;
|
||||
|
|
|
@ -2102,6 +2102,7 @@ sendPex( tr_peermsgs * msgs )
|
|||
tmp = walk = tr_new( uint8_t, diffs.addedCount * 6 );
|
||||
for( i = 0; i < diffs.addedCount; ++i )
|
||||
{
|
||||
tr_suspectAddress( &diffs.added[i].addr, "pex" );
|
||||
memcpy( walk, &diffs.added[i].addr.addr, 4 ); walk += 4;
|
||||
memcpy( walk, &diffs.added[i].port, 2 ); walk += 2;
|
||||
}
|
||||
|
@ -2132,6 +2133,7 @@ sendPex( tr_peermsgs * msgs )
|
|||
tmp = walk = tr_new( uint8_t, diffs6.addedCount * 18 );
|
||||
for( i = 0; i < diffs6.addedCount; ++i )
|
||||
{
|
||||
tr_suspectAddress( &diffs6.added[i].addr, "pex6" );
|
||||
memcpy( walk, &diffs6.added[i].addr.addr.addr6.s6_addr, 16 );
|
||||
walk += 16;
|
||||
memcpy( walk, &diffs6.added[i].port, 2 );
|
||||
|
|
|
@ -260,6 +260,7 @@ publishNewPeersCompact( tr_tracker * t,
|
|||
{
|
||||
memcpy( &addr.addr.addr4, compactWalk, 4 );
|
||||
memcpy( &port, compactWalk + 4, 2 );
|
||||
tr_suspectAddress( &addr, "compact" );
|
||||
|
||||
memcpy( walk, &addr, sizeof( addr ) );
|
||||
memcpy( walk + sizeof( addr ), &port, 2 );
|
||||
|
@ -291,6 +292,7 @@ publishNewPeersCompact6( tr_tracker * t,
|
|||
{
|
||||
memcpy( &addr.addr.addr6, compactWalk, 16 );
|
||||
memcpy( &port, compactWalk + 16, 2 );
|
||||
tr_suspectAddress( &addr, "compact6" );
|
||||
|
||||
memcpy( walk, &addr, sizeof( addr ) );
|
||||
memcpy( walk + sizeof( addr ), &port, 2 );
|
||||
|
@ -355,8 +357,8 @@ parseOldPeers( tr_benc * bePeers,
|
|||
const char * s;
|
||||
int64_t itmp;
|
||||
tr_address addr;
|
||||
tr_port port;
|
||||
tr_benc * peer = &bePeers->val.l.vals[i];
|
||||
tr_port port;
|
||||
tr_benc * peer = &bePeers->val.l.vals[i];
|
||||
|
||||
if( tr_bencDictFindStr( peer, "ip", &s ) )
|
||||
{
|
||||
|
@ -368,6 +370,7 @@ parseOldPeers( tr_benc * bePeers,
|
|||
continue;
|
||||
|
||||
memcpy( walk, &addr, sizeof( tr_address ) );
|
||||
tr_suspectAddress( &addr, "old tracker" );
|
||||
port = htons( itmp );
|
||||
memcpy( walk + sizeof( tr_address ), &port, 2 );
|
||||
walk += sizeof( tr_address ) + 2;
|
||||
|
|
Loading…
Reference in New Issue