Changeset 920 for trunk/cli


Ignore:
Timestamp:
Sep 25, 2006, 6:37:45 PM (15 years ago)
Author:
joshe
Message:

Merge nat-traversal branch to trunk.

Location:
trunk/cli
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/transmissioncli.1

    r261 r920  
    2727.Op Fl s Ar torrent-file
    2828.Op Fl v Ar level
     29.Op Fl n
    2930.Op Fl p Ar port
    3031.Op Fl u Ar upload-rate
     
    5152Sets debugging options.  The current range is 0-2, with the highest
    5253level producing the most output.  The default is 0.
     54.It Fl n, Fl -nat-traversal
     55Attempt to use the NAT-PMP and UPnP IGD protocols to establish a port
     56mapping for allowing incoming peer connections.
    5357.It Fl p, -port Ar port
    5458Specifies an alternate port for the client to listen on.  The default is
  • trunk/cli/transmissioncli.c

    r310 r920  
    3838"Usage: %s [options] file.torrent [options]\n\n" \
    3939"Options:\n" \
     40"  -d, --download <int> Maximum download rate (-1 = no limit, default = -1)\n"\
     41"  -f, --finish <shell script> Command you wish to run on completion\n" \
    4042"  -h, --help           Print this help and exit\n" \
    4143"  -i, --info           Print metainfo and exit\n" \
     44"  -n  --nat-traversal  Attempt NAT traversal using NAT-PMP or UPnP IGD\n" \
     45"  -p, --port <int>     Port we should listen on (default = %d)\n" \
    4246"  -s, --scrape         Print counts of seeders/leechers and exit\n" \
    43 "  -v, --verbose <int>  Verbose level (0 to 2, default = 0)\n" \
    44 "  -p, --port <int>     Port we should listen on (default = %d)\n" \
    4547"  -u, --upload <int>   Maximum upload rate (-1 = no limit, default = 20)\n" \
    46 "  -d, --download <int> Maximum download rate (-1 = no limit, default = -1)\n" \
    47 "  -f, --finish <shell script> Command you wish to run on completion\n"
     48"  -v, --verbose <int>  Verbose level (0 to 2, default = 0)\n"
    4849
    4950static int           showHelp      = 0;
     
    5657static char          * torrentPath = NULL;
    5758static volatile char mustDie       = 0;
     59static int           natTraversal  = 0;
    5860
    5961static char          * finishCall   = NULL;
     
    6466int main( int argc, char ** argv )
    6567{
    66     int i, error;
     68    int i, error, nat;
    6769    tr_handle_t  * h;
    6870    tr_torrent_t * tor;
     
    164166    tr_setUploadLimit( h, uploadLimit );
    165167    tr_setDownloadLimit( h, downloadLimit );
     168
     169    if( natTraversal )
     170    {
     171        tr_natTraversalEnable( h );
     172    }
     173    else
     174    {
     175        tr_natTraversalDisable( h );
     176    }
    166177   
    167178    tr_torrentSetFolder( tor, "." );
     
    201212        memset( &string[chars], ' ', 79 - chars );
    202213        string[79] = '\0';
    203         fprintf( stderr, "\r%s", string );
     214        //fprintf( stderr, "\r%s", string );
    204215
    205216        if( s->error & TR_ETRACKER )
     
    219230    fprintf( stderr, "\n" );
    220231
    221     /* Try for 5 seconds to notice the tracker that we are leaving */
     232    /* Try for 5 seconds to notify the tracker that we are leaving
     233       and to delete any port mappings for nat traversal */
    222234    tr_torrentStop( tor );
     235    tr_natTraversalDisable( h );
    223236    for( i = 0; i < 10; i++ )
    224237    {
    225238        s = tr_torrentStat( tor );
    226         if( s->status & TR_STATUS_PAUSE )
    227         {
    228             /* The 'stopped' message was sent */
     239        nat = tr_natTraversalStatus( h );
     240        if( s->status & TR_STATUS_PAUSE && TR_NAT_TRAVERSAL_DISABLED == nat )
     241        {
     242            /* The 'stopped' tracker message was sent
     243               and port mappings were deleted */
    229244            break;
    230245        }
     
    254269            { "download", required_argument, NULL, 'd' },
    255270            { "finish",   required_argument, NULL, 'f' },
     271            { "nat-traversal", no_argument,  NULL, 'n' },
    256272            { 0, 0, 0, 0} };
    257273
    258274        int c, optind = 0;
    259         c = getopt_long( argc, argv, "hisv:p:u:d:f:", long_options, &optind );
     275        c = getopt_long( argc, argv, "hisv:p:u:d:f:n", long_options, &optind );
    260276        if( c < 0 )
    261277        {
     
    287303            case 'f':
    288304                finishCall = optarg;
     305                break;
     306            case 'n':
     307                natTraversal = 1;
    289308                break;
    290309            default:
Note: See TracChangeset for help on using the changeset viewer.