Ignore:
Timestamp:
Apr 10, 2009, 5:34:25 PM (13 years ago)
Author:
charles
Message:

(1.5x libT) various backports for 1.52:
(1) recognize Aria2 as a client
(2) remove jhujhiti's tr_suspectAddress(), since he removed it from trunka
(3) on Mac, better detection of where the Web UI files are located
(4) reintroduce the web task queue
(5) various minor formatting changes to reduce the diffs between 1.52 and trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.5x/libtransmission/net.c

    r7852 r8204  
    128128}
    129129
    130 void
    131 tr_suspectAddress( const tr_address * a UNUSED, const char * source UNUSED )
    132 {
    133 /* this is overkill for a production environment,
    134  * but useful in the nightly builds, so only compile it into the nightlies */
    135 #ifdef TR_UNSTABLE
    136     /* be really aggressive in what we report */
    137     if( a->type == TR_AF_INET && !( ntohl( a->addr.addr4.s_addr ) & 0xff000000 ) )
    138         tr_err(  "Funny looking address %s from %s", tr_ntop_non_ts( a ), source );
    139     /* /16s taken from ipv6 rib on 21 dec, 2008 */
    140     /* this is really, really ugly. expedience over quality */
    141     if( a->type == TR_AF_INET6 )
    142     {
    143         uint16_t slash16;
    144         uint16_t valid[] = { 0x339, 0x2002, 0x2003, 0x2400, 0x2401, 0x2402,
    145             0x2403, 0x2404, 0x2405, 0x2406, 0x2407, 0x2600, 0x2607, 0x2610,
    146             0x2620, 0x2800, 0x2801, 0x2a00, 0x2a01, 0x0a02, 0x2001, 0x0000 };
    147         uint16_t *p;
    148         tr_bool good = FALSE;
    149         p = valid;
    150         memcpy( &slash16, &a->addr, 2 );
    151         slash16 = ntohs( slash16 );
    152         while( *p )
    153         {
    154             if( slash16 == *p )
    155                 good = TRUE;
    156             p++;
    157         }
    158         if( !good && !IN6_IS_ADDR_V4MAPPED( &a->addr.addr6 ) )
    159             tr_err(  "Funny looking address %s from %s", tr_ntop_non_ts( a ), source );
    160     }
    161 #endif
    162 }
    163 
    164130const char *
    165131tr_ntop( const tr_address * src, char * dst, int size )
     
    205171}
    206172
    207 void
    208 tr_normalizeV4Mapped( tr_address * const addr )
    209 {
    210     assert( tr_isAddress( addr ) );
    211 
    212     if( addr->type == TR_AF_INET6 && IN6_IS_ADDR_V4MAPPED( &addr->addr.addr6 ) )
    213     {
    214         addr->type = TR_AF_INET;
    215         memcpy( &addr->addr.addr4.s_addr, addr->addr.addr6.s6_addr + 12, 4 );
    216     }
    217 }
    218 
    219173/*
    220174 * Compare two tr_address structures.
     
    464418
    465419static TR_INLINE tr_bool
     420isIPv4MappedOrCompatAddress( const tr_address * addr )
     421{
     422    if( addr->type == TR_AF_INET6 )
     423    {
     424        if( IN6_IS_ADDR_V4MAPPED( &addr->addr.addr6 ) ||
     425            IN6_IS_ADDR_V4COMPAT( &addr->addr.addr6 ) )
     426            return TRUE;
     427    }
     428    return FALSE;
     429}
     430
     431static TR_INLINE tr_bool
    466432isIPv6LinkLocalAddress( const tr_address * addr )
    467433{
    468434    if( addr->type == TR_AF_INET6 &&
    469             IN6_IS_ADDR_LINKLOCAL( &addr->addr.addr6 ))
     435        IN6_IS_ADDR_LINKLOCAL( &addr->addr.addr6 ) )
    470436        return TRUE;
    471437    return FALSE;
     
    475441tr_isValidPeerAddress( const tr_address * addr, tr_port port )
    476442{
    477     if( isMulticastAddress( addr ) || isIPv6LinkLocalAddress( addr ) )
     443    if( isMulticastAddress( addr ) || isIPv6LinkLocalAddress( addr ) ||
     444        isIPv4MappedOrCompatAddress( addr ) )
    478445        return FALSE;
    479446
     
    496463    assert( tr_isAddress( addr ) );
    497464
    498     if( isMulticastAddress( addr ) || isIPv6LinkLocalAddress( addr ))
     465    if( isMulticastAddress( addr ) || isIPv6LinkLocalAddress( addr ) )
    499466        return -EINVAL;
    500467
Note: See TracChangeset for help on using the changeset viewer.