Ignore:
Timestamp:
Nov 10, 2009, 5:03:23 PM (12 years ago)
Author:
charles
Message:

(trunk libT) #2112: provide "ipv6=" parameter to trackers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/net.c

    r9499 r9513  
    604604    }
    605605}
     606
     607/* Return our global IPv6 address, with caching. */
     608
     609const unsigned char *
     610tr_globalIPv6( void )
     611{
     612    static unsigned char ipv6[16];
     613    static time_t last_time = 0;
     614    static int have_ipv6 = 0;
     615    const time_t now = time( NULL );
     616
     617    /* Re-check every half hour */
     618    if( last_time < now - 1800 )
     619    {
     620        int addrlen = 16;
     621        const int rc = tr_globalAddress( AF_INET6, ipv6, &addrlen );
     622        have_ipv6 = ( rc >= 0 ) && ( addrlen == 16 );
     623        last_time = now;
     624    }
     625
     626    return have_ipv6 ? ipv6 : NULL;
     627}
Note: See TracChangeset for help on using the changeset viewer.