1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 16:24:02 +00:00

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

This commit is contained in:
Charles Kerr 2008-11-04 17:04:41 +00:00
parent 4ec4c07929
commit b4d5883c17
2 changed files with 46 additions and 29 deletions

View file

@ -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,35 +930,51 @@ printFileList( tr_benc * top )
}
static void
printPeerList( tr_benc * top )
{
tr_benc *args, *list;
if( ( tr_bencDictFindDict( top, "arguments", &args ) )
&& ( tr_bencDictFindList( args, "peers", &list ) ) )
printPeersImpl( tr_benc * peers )
{
int i, n;
printf( "%-20s %-12s %-5s %5s %s\n",
printf( "%-20s %-12s %-6s %-6s %s\n",
"Address", "Flags", "Down", "Up", "Client" );
for( i = 0, n = tr_bencListSize( list ); i < n; ++i )
for( i = 0, n = tr_bencListSize( peers ); i < n; ++i )
{
const char * address, * client, * flagstr;
int64_t rateToClient, rateToPeer;
tr_benc * d = tr_bencListChild( list, i );
tr_benc * d = tr_bencListChild( peers, i );
if( tr_bencDictFindStr( d, "address", &address )
&& tr_bencDictFindStr( d, "client", &client )
&& tr_bencDictFindStr( d, "flagstr", &flagstr )
&& tr_bencDictFindStr( d, "clientName", &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",
printf( "%-20s %-12s %6.1f %6.1f %s\n",
address, flagstr,
rateToClient * 1024.0,
rateToPeer * 1024.0,
rateToClient / 1024.0,
rateToPeer / 1024.0,
client );
}
}
}
static void
printPeers( tr_benc * top )
{
tr_benc *args, *torrents;
if( tr_bencDictFindDict( top, "arguments", &args )
&& tr_bencDictFindList( args, "torrents", &torrents ) )
{
int i, n;
for( i=0, n=tr_bencListSize( torrents ); i<n; ++i )
{
tr_benc * peers;
tr_benc * torrent = tr_bencListChild( torrents, i );
if( tr_bencDictFindList( torrent, "peers", &peers ) ) {
printPeersImpl( peers );
if( i+1<n )
printf( "\n" );
}
}
}
}
static void
@ -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 ) );

View file

@ -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