Changeset 11610


Ignore:
Timestamp:
Dec 30, 2010, 7:15:47 PM (10 years ago)
Author:
charles
Message:

(trunk libT) #3528 "TR_PREFS_KEY_BIND_ADDRESS_IPV4 breaks IPv6-only trackers" -- Implement suggestion #2 from Harry

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/net.c

    r11599 r11610  
    316316
    317317    /* set source address */
    318     source_addr = tr_sessionGetPublicAddress( session, addr->type );
     318    source_addr = tr_sessionGetPublicAddress( session, addr->type, NULL );
    319319    assert( source_addr );
    320320    sourcelen = setup_sockaddr( source_addr, 0, &source_sock );
  • trunk/libtransmission/session.c

    r11599 r11610  
    219219
    220220const tr_address*
    221 tr_sessionGetPublicAddress( const tr_session * session, int tr_af_type )
    222 {
     221tr_sessionGetPublicAddress( const tr_session * session, int tr_af_type, tr_bool * is_default_value )
     222{
     223    const char * default_value;
    223224    const struct tr_bindinfo * bindinfo;
    224225
    225226    switch( tr_af_type )
    226227    {
    227         case TR_AF_INET:  bindinfo = session->public_ipv4; break;
    228         case TR_AF_INET6: bindinfo = session->public_ipv6; break;
    229         default:          bindinfo = NULL;                 break;
    230     }
     228        case TR_AF_INET:
     229            bindinfo = session->public_ipv4;
     230            default_value = TR_DEFAULT_BIND_ADDRESS_IPV4;
     231            break;
     232
     233        case TR_AF_INET6:
     234            bindinfo = session->public_ipv6;
     235            default_value = TR_DEFAULT_BIND_ADDRESS_IPV6;
     236            break;
     237
     238        default:
     239            bindinfo = NULL;
     240            default_value = "";
     241            break;
     242    }
     243
     244    if( is_default_value != NULL )
     245        *is_default_value = !strcmp( default_value, tr_ntop_non_ts( &bindinfo->addr ) );
    231246
    232247    return bindinfo ? &bindinfo->addr : NULL;
  • trunk/libtransmission/session.h

    r11599 r11610  
    225225tr_bool      tr_sessionIsLocked( const tr_session * );
    226226
    227 const struct tr_address*  tr_sessionGetPublicAddress( const tr_session *, int tr_af_type );
     227const struct tr_address*  tr_sessionGetPublicAddress( const tr_session  * session,
     228                                                      int                 tr_af_type,
     229                                                      tr_bool           * is_default_value );
     230
    228231
    229232struct tr_bindsockets * tr_sessionGetBindSockets( tr_session * );
  • trunk/libtransmission/web.c

    r11599 r11610  
    144144{
    145145    const tr_address * addr;
     146    tr_bool is_default_value;
    146147    CURL * e = curl_easy_init( );
    147148    const long verbose = getenv( "TR_CURL_VERBOSE" ) != NULL;
     
    168169    curl_easy_setopt( e, CURLOPT_WRITEFUNCTION, writeFunc );
    169170
    170     if(( addr = tr_sessionGetPublicAddress( s, TR_AF_INET )))
     171    if((( addr = tr_sessionGetPublicAddress( s, TR_AF_INET, &is_default_value ))) && !is_default_value )
     172        curl_easy_setopt( e, CURLOPT_INTERFACE, tr_ntop_non_ts( addr ) );
     173    else if ((( addr = tr_sessionGetPublicAddress( s, TR_AF_INET6, &is_default_value ))) && !is_default_value )
    171174        curl_easy_setopt( e, CURLOPT_INTERFACE, tr_ntop_non_ts( addr ) );
    172175
Note: See TracChangeset for help on using the changeset viewer.