(trunk libT) make IPv6's two IPv4-compatible address formats invalid peer addresses
IPv4 peers should only be seen from an IPv4-connected tracker.
This commit is contained in:
parent
dd7eb76718
commit
2f8d56e77f
|
@ -170,18 +170,6 @@ tr_pton( const char * src, tr_address * dst )
|
|||
return dst;
|
||||
}
|
||||
|
||||
void
|
||||
tr_normalizeV4Mapped( tr_address * const addr )
|
||||
{
|
||||
assert( tr_isAddress( addr ) );
|
||||
|
||||
if( addr->type == TR_AF_INET6 && IN6_IS_ADDR_V4MAPPED( &addr->addr.addr6 ) )
|
||||
{
|
||||
addr->type = TR_AF_INET;
|
||||
memcpy( &addr->addr.addr4.s_addr, addr->addr.addr6.s6_addr + 12, 4 );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare two tr_address structures.
|
||||
* Returns:
|
||||
|
@ -428,6 +416,18 @@ isMulticastAddress( const tr_address * addr )
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static TR_INLINE tr_bool
|
||||
isIPv4MappedOrCompatAddress( const tr_address * addr )
|
||||
{
|
||||
if( addr->type == TR_AF_INET6 )
|
||||
{
|
||||
if( IN6_IS_ADDR_V4MAPPED( &addr->addr.addr6 ) ||
|
||||
IN6_IS_ADDR_V4COMPAT( &addr->addr.addr6 ) )
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static TR_INLINE tr_bool
|
||||
isIPv6LinkLocalAddress( const tr_address * addr )
|
||||
{
|
||||
|
@ -440,7 +440,8 @@ isIPv6LinkLocalAddress( const tr_address * addr )
|
|||
tr_bool
|
||||
tr_isValidPeerAddress( const tr_address * addr, tr_port port )
|
||||
{
|
||||
if( isMulticastAddress( addr ) || isIPv6LinkLocalAddress( addr ) )
|
||||
if( isMulticastAddress( addr ) || isIPv6LinkLocalAddress( addr ) ||
|
||||
isIPv4MappedOrCompatAddress( addr ) )
|
||||
return FALSE;
|
||||
|
||||
if( port == 0 )
|
||||
|
|
|
@ -86,7 +86,6 @@ tr_address *tr_pton( const char * src,
|
|||
tr_address * dst );
|
||||
int tr_compareAddresses( const tr_address * a,
|
||||
const tr_address * b);
|
||||
void tr_normalizeV4Mapped( tr_address * const addr );
|
||||
|
||||
tr_bool tr_isValidPeerAddress( const tr_address * addr, tr_port port );
|
||||
|
||||
|
|
|
@ -1830,11 +1830,8 @@ tr_peerMgrPeerStats( const tr_torrent * tor,
|
|||
const tr_peer * peer = peers[i];
|
||||
const struct peer_atom * atom = getExistingAtom( t, &peer->addr );
|
||||
tr_peer_stat * stat = ret + i;
|
||||
tr_address norm_addr;
|
||||
|
||||
norm_addr = peer->addr;
|
||||
tr_normalizeV4Mapped( &norm_addr );
|
||||
tr_ntop( &norm_addr, stat->addr, sizeof( stat->addr ) );
|
||||
tr_ntop( &peer->addr, stat->addr, sizeof( stat->addr ) );
|
||||
tr_strlcpy( stat->client, ( peer->client ? peer->client : "" ),
|
||||
sizeof( stat->client ) );
|
||||
stat->port = ntohs( peer->port );
|
||||
|
|
Loading…
Reference in New Issue