Changeset 7038


Ignore:
Timestamp:
Nov 4, 2008, 5:04:41 PM (10 years ago)
Author:
charles
Message:

(daemon) #1420: transmission-remote --peers doesn't work right

Location:
trunk/daemon
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/remote.c

    r7006 r7038  
    443443                tr_bencDictAddStr( &top, "method", "torrent-get" );
    444444                tr_bencDictAddInt( &top, "tag", TAG_PEERS );
     445                addIdArg( args, id );
    445446                fields = tr_bencDictAddList( args, "fields", 1 );
    446447                tr_bencListAddStr( fields, "peers" );
     
    930931
    931932static void
    932 printPeerList( tr_benc * top )
    933 {
    934     tr_benc *args, *list;
    935 
    936     if( ( tr_bencDictFindDict( top, "arguments", &args ) )
    937       && ( tr_bencDictFindList( args, "peers", &list ) ) )
     933printPeersImpl( tr_benc * peers )
     934{
     935    int i, n;
     936    printf( "%-20s  %-12s  %-6s  %-6s  %s\n",
     937            "Address", "Flags", "Down", "Up", "Client" );
     938    for( i = 0, n = tr_bencListSize( peers ); i < n; ++i )
     939    {
     940        const char * address, * client, * flagstr;
     941        int64_t      rateToClient, rateToPeer;
     942        tr_benc *    d = tr_bencListChild( peers, i );
     943        if( tr_bencDictFindStr( d, "address", &address )
     944          && tr_bencDictFindStr( d, "clientName", &client )
     945          && tr_bencDictFindStr( d, "flagStr", &flagstr )
     946          && tr_bencDictFindInt( d, "rateToClient", &rateToClient )
     947          && tr_bencDictFindInt( d, "rateToPeer", &rateToPeer ) )
     948        {
     949            printf( "%-20s  %-12s  %6.1f  %6.1f  %s\n",
     950                    address, flagstr,
     951                    rateToClient / 1024.0,
     952                    rateToPeer / 1024.0,
     953                    client );
     954        }
     955    }
     956}
     957
     958static void
     959printPeers( tr_benc * top )
     960{
     961    tr_benc *args, *torrents;
     962
     963    if( tr_bencDictFindDict( top, "arguments", &args )
     964      && tr_bencDictFindList( args, "torrents", &torrents ) )
    938965    {
    939966        int i, n;
    940         printf( "%-20s  %-12s  %-5s  %5s  %s\n",
    941                 "Address", "Flags", "Down", "Up", "Client" );
    942         for( i = 0, n = tr_bencListSize( list ); i < n; ++i )
    943         {
    944             const char * address, * client, * flagstr;
    945             int64_t      rateToClient, rateToPeer;
    946             tr_benc *    d = tr_bencListChild( list, i );
    947             if( tr_bencDictFindStr( d, "address", &address )
    948               && tr_bencDictFindStr( d, "client", &client )
    949               && tr_bencDictFindStr( d, "flagstr", &flagstr )
    950               && tr_bencDictFindInt( d, "rateToClient", &rateToClient )
    951               && tr_bencDictFindInt( d, "rateToPeer", &rateToPeer ) )
    952             {
    953                 printf( "%-20s  %-12s  %5.1f  %5.1f  %s\n",
    954                         address, flagstr,
    955                         rateToClient * 1024.0,
    956                         rateToPeer * 1024.0,
    957                         client );
     967        for( i=0, n=tr_bencListSize( torrents ); i<n; ++i )
     968        {
     969            tr_benc * peers;
     970            tr_benc * torrent = tr_bencListChild( torrents, i );
     971            if( tr_bencDictFindList( torrent, "peers", &peers ) ) {
     972                printPeersImpl( peers );
     973                if( i+1<n )
     974                    printf( "\n" );
    958975            }
    959976        }
     
    10471064
    10481065            case TAG_PEERS:
    1049                 printPeerList( &top ); break;
     1066                printPeers( &top ); break;
    10501067
    10511068            default:
     
    10921109        curl_easy_setopt( curl, CURLOPT_POSTFIELDS, reqs[i] );
    10931110        if( debug )
    1094             tr_ninf( MY_NAME, "posting [%s]\n", reqs[i] );
     1111            fprintf( stderr, "posting [%s]\n", reqs[i] );
    10951112        if( ( res = curl_easy_perform( curl ) ) )
    10961113            tr_nerr( MY_NAME, "(%s:%d) %s", host, port,
  • trunk/daemon/transmission-remote.1

    r6634 r7038  
    171171Disable peer exchange (PEX).
    172172
    173 .It Fl x Fl -peers
     173.It Fl z Fl -peers
    174174List the current torrent's connected peers.
    175175In the `status' section of the list, the following shorthand is used:
     
    221221Get detailed information on the torrent whose ID is '1':
    222222.Bd -literal -offset indent
    223 $ transmission-remote -t1 -i"
     223$ transmission-remote -t1 -i
    224224.Ed
    225225
    226226Get a list of a torrent's files:
    227227.Bd -literal -offset indent
    228 $ transmission-remote -t1 -l"
     228$ transmission-remote -t1 -l
    229229.Ed
    230230
    231231Download only its second and fourth files:
    232232.Bd -literal -offset indent
    233 $ transmission-remote -t1 -Gall -g2,4"
     233$ transmission-remote -t1 -Gall -g2,4
    234234.Ed
    235235
    236236Set all torrents' first two files' priorities to high:
    237237.Bd -literal -offset indent
    238 $ transmission-remote -tall -ph1,2"
     238$ transmission-remote -tall -ph1,2
    239239.Ed
    240240
    241241Set all torrents' files' priorities to normal:
    242242.Bd -literal -offset indent
    243 $ transmission-remote -tall -pnall"
     243$ transmission-remote -tall -pnall
    244244.Ed
    245245
Note: See TracChangeset for help on using the changeset viewer.