mirror of
https://github.com/transmission/transmission
synced 2024-12-23 08:13:27 +00:00
(daemon) #1420: transmission-remote --peers doesn't work right
This commit is contained in:
parent
4ec4c07929
commit
b4d5883c17
2 changed files with 46 additions and 29 deletions
|
@ -442,6 +442,7 @@ readargs( int argc,
|
|||
case 'z':
|
||||
tr_bencDictAddStr( &top, "method", "torrent-get" );
|
||||
tr_bencDictAddInt( &top, "tag", TAG_PEERS );
|
||||
addIdArg( args, id );
|
||||
fields = tr_bencDictAddList( args, "fields", 1 );
|
||||
tr_bencListAddStr( fields, "peers" );
|
||||
break;
|
||||
|
@ -929,32 +930,48 @@ printFileList( tr_benc * top )
|
|||
}
|
||||
|
||||
static void
|
||||
printPeerList( tr_benc * top )
|
||||
printPeersImpl( tr_benc * peers )
|
||||
{
|
||||
tr_benc *args, *list;
|
||||
int i, n;
|
||||
printf( "%-20s %-12s %-6s %-6s %s\n",
|
||||
"Address", "Flags", "Down", "Up", "Client" );
|
||||
for( i = 0, n = tr_bencListSize( peers ); i < n; ++i )
|
||||
{
|
||||
const char * address, * client, * flagstr;
|
||||
int64_t rateToClient, rateToPeer;
|
||||
tr_benc * d = tr_bencListChild( peers, i );
|
||||
if( tr_bencDictFindStr( d, "address", &address )
|
||||
&& tr_bencDictFindStr( d, "clientName", &client )
|
||||
&& tr_bencDictFindStr( d, "flagStr", &flagstr )
|
||||
&& tr_bencDictFindInt( d, "rateToClient", &rateToClient )
|
||||
&& tr_bencDictFindInt( d, "rateToPeer", &rateToPeer ) )
|
||||
{
|
||||
printf( "%-20s %-12s %6.1f %6.1f %s\n",
|
||||
address, flagstr,
|
||||
rateToClient / 1024.0,
|
||||
rateToPeer / 1024.0,
|
||||
client );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( ( tr_bencDictFindDict( top, "arguments", &args ) )
|
||||
&& ( tr_bencDictFindList( args, "peers", &list ) ) )
|
||||
static void
|
||||
printPeers( tr_benc * top )
|
||||
{
|
||||
tr_benc *args, *torrents;
|
||||
|
||||
if( tr_bencDictFindDict( top, "arguments", &args )
|
||||
&& tr_bencDictFindList( args, "torrents", &torrents ) )
|
||||
{
|
||||
int i, n;
|
||||
printf( "%-20s %-12s %-5s %5s %s\n",
|
||||
"Address", "Flags", "Down", "Up", "Client" );
|
||||
for( i = 0, n = tr_bencListSize( list ); i < n; ++i )
|
||||
for( i=0, n=tr_bencListSize( torrents ); i<n; ++i )
|
||||
{
|
||||
const char * address, * client, * flagstr;
|
||||
int64_t rateToClient, rateToPeer;
|
||||
tr_benc * d = tr_bencListChild( list, i );
|
||||
if( tr_bencDictFindStr( d, "address", &address )
|
||||
&& tr_bencDictFindStr( d, "client", &client )
|
||||
&& tr_bencDictFindStr( d, "flagstr", &flagstr )
|
||||
&& tr_bencDictFindInt( d, "rateToClient", &rateToClient )
|
||||
&& tr_bencDictFindInt( d, "rateToPeer", &rateToPeer ) )
|
||||
{
|
||||
printf( "%-20s %-12s %5.1f %5.1f %s\n",
|
||||
address, flagstr,
|
||||
rateToClient * 1024.0,
|
||||
rateToPeer * 1024.0,
|
||||
client );
|
||||
tr_benc * peers;
|
||||
tr_benc * torrent = tr_bencListChild( torrents, i );
|
||||
if( tr_bencDictFindList( torrent, "peers", &peers ) ) {
|
||||
printPeersImpl( peers );
|
||||
if( i+1<n )
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1046,7 +1063,7 @@ processResponse( const char * host,
|
|||
printTorrentList( &top ); break;
|
||||
|
||||
case TAG_PEERS:
|
||||
printPeerList( &top ); break;
|
||||
printPeers( &top ); break;
|
||||
|
||||
default:
|
||||
if( tr_bencDictFindStr( &top, "result", &str ) )
|
||||
|
@ -1091,7 +1108,7 @@ processRequests( const char * host,
|
|||
CURLcode res;
|
||||
curl_easy_setopt( curl, CURLOPT_POSTFIELDS, reqs[i] );
|
||||
if( debug )
|
||||
tr_ninf( MY_NAME, "posting [%s]\n", reqs[i] );
|
||||
fprintf( stderr, "posting [%s]\n", reqs[i] );
|
||||
if( ( res = curl_easy_perform( curl ) ) )
|
||||
tr_nerr( MY_NAME, "(%s:%d) %s", host, port,
|
||||
curl_easy_strerror( res ) );
|
||||
|
|
|
@ -170,7 +170,7 @@ Enable peer exchange (PEX).
|
|||
.It Fl X Fl -no-pex
|
||||
Disable peer exchange (PEX).
|
||||
|
||||
.It Fl x Fl -peers
|
||||
.It Fl z Fl -peers
|
||||
List the current torrent's connected peers.
|
||||
In the `status' section of the list, the following shorthand is used:
|
||||
.D1 D: Downloading from this peer
|
||||
|
@ -220,27 +220,27 @@ $ transmission-remote -a ~/Desktop/*torrent
|
|||
|
||||
Get detailed information on the torrent whose ID is '1':
|
||||
.Bd -literal -offset indent
|
||||
$ transmission-remote -t1 -i"
|
||||
$ transmission-remote -t1 -i
|
||||
.Ed
|
||||
|
||||
Get a list of a torrent's files:
|
||||
.Bd -literal -offset indent
|
||||
$ transmission-remote -t1 -l"
|
||||
$ transmission-remote -t1 -l
|
||||
.Ed
|
||||
|
||||
Download only its second and fourth files:
|
||||
.Bd -literal -offset indent
|
||||
$ transmission-remote -t1 -Gall -g2,4"
|
||||
$ transmission-remote -t1 -Gall -g2,4
|
||||
.Ed
|
||||
|
||||
Set all torrents' first two files' priorities to high:
|
||||
.Bd -literal -offset indent
|
||||
$ transmission-remote -tall -ph1,2"
|
||||
$ transmission-remote -tall -ph1,2
|
||||
.Ed
|
||||
|
||||
Set all torrents' files' priorities to normal:
|
||||
.Bd -literal -offset indent
|
||||
$ transmission-remote -tall -pnall"
|
||||
$ transmission-remote -tall -pnall
|
||||
.Ed
|
||||
|
||||
.Sh AUTHORS
|
||||
|
|
Loading…
Reference in a new issue