Ignore:
Timestamp:
Dec 13, 2007, 6:56:22 PM (15 years ago)
Author:
charles
Message:

take pea_'s suggestion of not sending out natpmp/upnp discover messages until port forwarding is enabled

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/upnp.c

    r4142 r4154  
    5757{
    5858    tr_upnp * ret = tr_new0( tr_upnp, 1 );
     59    ret->state = TR_UPNP_DISCOVER;
    5960    ret->port = -1;
    6061    return ret;
     
    8182    int ret;
    8283
    83     if( handle->state == TR_UPNP_IDLE )
    84     {
    85         if( !handle->hasDiscovered )
    86             handle->state = TR_UPNP_DISCOVER;
    87     }
    88 
    89     if( handle->state == TR_UPNP_DISCOVER )
     84    if( isEnabled && ( handle->state == TR_UPNP_DISCOVER ) )
    9085    {
    9186        struct UPNPDev * devlist;
     
    158153    }
    159154
    160     if( handle->state == TR_UPNP_ERR )
    161         ret = TR_NAT_TRAVERSAL_ERROR;
    162     else if( ( handle->state == TR_UPNP_IDLE ) && handle->isMapped )
    163         ret = TR_NAT_TRAVERSAL_MAPPED;
    164     else if( ( handle->state == TR_UPNP_IDLE ) && !handle->isMapped )
    165         ret = TR_NAT_TRAVERSAL_UNMAPPED;
    166     else if( handle->state == TR_UPNP_MAP )
    167         ret = TR_NAT_TRAVERSAL_MAPPING;
    168     else if( handle->state == TR_UPNP_UNMAP )
    169         ret = TR_NAT_TRAVERSAL_UNMAPPING;
     155    switch( handle->state )
     156    {
     157        case TR_UPNP_DISCOVER: ret = TR_NAT_TRAVERSAL_UNMAPPED; break;
     158        case TR_UPNP_MAP:      ret = TR_NAT_TRAVERSAL_MAPPING; break;
     159        case TR_UPNP_UNMAP:    ret = TR_NAT_TRAVERSAL_UNMAPPING; break;
     160        case TR_UPNP_IDLE:     ret = handle->isMapped ? TR_NAT_TRAVERSAL_MAPPED
     161                                                      : TR_NAT_TRAVERSAL_UNMAPPED; break;
     162        default:               ret = TR_NAT_TRAVERSAL_ERROR; break;
     163    }
     164
    170165    return ret;
    171166}
Note: See TracChangeset for help on using the changeset viewer.