mirror of
https://github.com/transmission/transmission
synced 2025-03-03 18:25:35 +00:00
(trunk libT) #1723: View version with / from transmission-remote
This commit is contained in:
parent
85bf1865a5
commit
61fd825e89
4 changed files with 74 additions and 1 deletions
|
@ -66,6 +66,7 @@ static const struct tr_option options[] =
|
|||
{ 'T', "no-auth", "Don't require authentication", "T", 0, NULL },
|
||||
{ 'u', "username", "Set username for authentication", "u", 1, "<username>" },
|
||||
{ 'v', "password", "Set password for authentication", "v", 1, "<password>" },
|
||||
{ 'V', "version", "Show version number and exit", "V", 0, NULL },
|
||||
{ 'w', "download-dir", "Where to save downloaded data", "w", 1, "<path>" },
|
||||
{ 'P', "peerport", "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "P", 1, "<port>" },
|
||||
{ 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", 0, NULL },
|
||||
|
@ -215,6 +216,9 @@ main( int argc,
|
|||
break;
|
||||
case 'g': /* handled above */
|
||||
break;
|
||||
case 'V': /* version */
|
||||
fprintf(stderr, "Transmission %s\n", LONG_VERSION_STRING);
|
||||
exit( 0 );
|
||||
case 'p': tr_bencDictAddInt( &settings, TR_PREFS_KEY_RPC_PORT, atoi( optarg ) );
|
||||
break;
|
||||
case 't': tr_bencDictAddInt( &settings, TR_PREFS_KEY_RPC_AUTH_REQUIRED, 1 );
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#define DEFAULT_HOST "localhost"
|
||||
#define DEFAULT_PORT atoi(TR_DEFAULT_RPC_PORT_STR)
|
||||
|
||||
enum { TAG_LIST, TAG_DETAILS, TAG_FILES, TAG_PEERS };
|
||||
enum { TAG_SESSION, TAG_LIST, TAG_DETAILS, TAG_FILES, TAG_PEERS };
|
||||
|
||||
static const char*
|
||||
getUsage( void )
|
||||
|
@ -79,12 +79,14 @@ static tr_option opts[] =
|
|||
{ 902, "priority-low", "Set the files' priorities as low", "pl", 1, "<files>" },
|
||||
{ 'r', "remove", "Remove the current torrent(s)", "r", 0, NULL },
|
||||
{ 'R', "remove-and-delete", "Remove the current torrent(s) and delete local data", NULL, 0, NULL },
|
||||
{ 920, "session", "Print session information", NULL, 0, NULL },
|
||||
{ 's', "start", "Start the current torrent(s)", "s", 0, NULL },
|
||||
{ 'S', "stop", "Stop the current torrent(s)", "S", 0, NULL },
|
||||
{ 't', "torrent", "Set the current torrent(s)", "t", 1, "<torrent>" },
|
||||
{ 'u', "uplimit", "Set the maximum global upload speed in KB/s", "u", 1, "<speed>" },
|
||||
{ 'U', "no-uplimit", "Don't limit the global upload speed", "U", 0, NULL },
|
||||
{ 'v', "verify", "Verify the current torrent(s)", "v", 0, NULL },
|
||||
{ 'V', "version", "Show version number and exit", "V", 0, NULL },
|
||||
{ 'w', "download-dir", "Set the default download folder", "w", 1, "<path>" },
|
||||
{ 'x', "pex", "Enable peer exchange (PEX)", "x", 0, NULL },
|
||||
{ 'X', "no-pex", "Disable peer exchange (PEX)", "X", 0, NULL },
|
||||
|
@ -435,6 +437,11 @@ readargs( int argc,
|
|||
addIdArg( args, id );
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
fprintf(stderr, "Transmission %s\n", LONG_VERSION_STRING);
|
||||
exit(0);
|
||||
break;
|
||||
|
||||
case 'w': {
|
||||
char * path = absolutify( optarg );
|
||||
tr_bencDictAddStr( &top, "method", "session-set" );
|
||||
|
@ -494,6 +501,11 @@ readargs( int argc,
|
|||
tr_bencDictAddStr( args, "encryption", "tolerated" );
|
||||
break;
|
||||
|
||||
case 920:
|
||||
tr_bencDictAddStr( &top, "method", "session-get" );
|
||||
tr_bencDictAddInt( &top, "tag", TAG_SESSION );
|
||||
break;
|
||||
|
||||
case TR_OPT_ERR:
|
||||
fprintf( stderr, "invalid option\n" );
|
||||
showUsage( );
|
||||
|
@ -713,6 +725,52 @@ getTrackerDateStr( const time_t t, tr_bool isStopped )
|
|||
return str;
|
||||
}
|
||||
|
||||
static void
|
||||
printSession( tr_benc * top )
|
||||
{
|
||||
tr_benc *args;
|
||||
if( ( tr_bencDictFindDict( top, "arguments", &args ) ) )
|
||||
{
|
||||
const char * str;
|
||||
int64_t i;
|
||||
|
||||
printf( "VERSION\n" );
|
||||
if( tr_bencDictFindStr( args, "version", &str ) )
|
||||
printf( " Daemon version: %s\n", str );
|
||||
if( tr_bencDictFindInt( args, "rpc-version", &i ) )
|
||||
printf( " RPC version: %" PRId64 "\n", i );
|
||||
if( tr_bencDictFindInt( args, "rpc-version-minimum", &i ) )
|
||||
printf( " RPC minimum version: %" PRId64 "\n", i );
|
||||
printf( "\n" );
|
||||
|
||||
printf( "TRANSFER\n" );
|
||||
if( tr_bencDictFindStr( args, "download-dir", &str ) )
|
||||
printf( " Download directory: %s\n", str );
|
||||
if( tr_bencDictFindInt( args, "port", &i ) )
|
||||
printf( " Listenport: %" PRId64 "\n", i );
|
||||
if( tr_bencDictFindInt( args, "port-forwarding-enabled", &i ) )
|
||||
printf( " Portforwarding enabled: %s\n", ( i ? "Yes" : "No" ) );
|
||||
if( tr_bencDictFindInt( args, "pex-allowed", &i ) )
|
||||
printf( " Peer exchange allowed: %s\n", ( i ? "Yes" : "No" ) );
|
||||
if( tr_bencDictFindStr( args, "encryption", &str ) )
|
||||
printf( " Encryption: %s\n", str );
|
||||
printf( "\n" );
|
||||
|
||||
printf( "LIMITS\n" );
|
||||
if( tr_bencDictFindInt( args, "peer-limit", &i ) )
|
||||
printf( " Peer limit: %" PRId64 "\n", i );
|
||||
if( tr_bencDictFindInt( args, "speed-limit-down-enabled", &i ) )
|
||||
printf( " Downloadlimit enabled: %s\n", ( i ? "Yes" : "No" ) );
|
||||
if( tr_bencDictFindInt( args, "speed-limit-down", &i ) )
|
||||
printf( " Downloadlimit: %6" PRId64 " KB/sec\n", i );
|
||||
if( tr_bencDictFindInt( args, "speed-limit-up-enabled", &i ) )
|
||||
printf( " Uploadlimit enabled: %s\n", ( i ? "Yes" : "No" ) );
|
||||
if( tr_bencDictFindInt( args, "speed-limit-up", &i ) )
|
||||
printf( " Uploadlimit: %6" PRId64 " KB/sec\n", i );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
printDetails( tr_benc * top )
|
||||
{
|
||||
|
@ -1086,6 +1144,9 @@ processResponse( const char * host,
|
|||
|
||||
switch( tag )
|
||||
{
|
||||
case TAG_SESSION:
|
||||
printSession( &top ); break;
|
||||
|
||||
case TAG_FILES:
|
||||
printFileList( &top ); break;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
.Op Fl l Ar limit
|
||||
.Op Fl L Ar limit
|
||||
.Op Fl er | ep | et
|
||||
.Op Fl V
|
||||
.Op Fl w Ar download-dir
|
||||
.Ek
|
||||
|
||||
|
@ -97,6 +98,9 @@ Used for client authentication.
|
|||
.It Fl v Fl -password Ar password
|
||||
Used for client authentication.
|
||||
|
||||
.It Fl V Fl -version
|
||||
Show version number and exit
|
||||
|
||||
.It Fl w Fl -download-dir
|
||||
Where to store downloaded data.
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ and
|
|||
.Op Fl t Ar all | Ar id | Ar hash
|
||||
.Op Fl u Ar number | Fl U
|
||||
.Op Fl v
|
||||
.Op Fl V
|
||||
.Op Fl w Ar download-dir
|
||||
.Op Fl x | X
|
||||
.Op Fl z | peers
|
||||
|
@ -162,6 +163,9 @@ Remove the global upload limit.
|
|||
.It Fl v Fl -verify
|
||||
Verify the current torrent(s)
|
||||
|
||||
.It Fl V Fl -version
|
||||
Show version number and exit
|
||||
|
||||
.It Fl w Fl -download-dir Ar directory
|
||||
Use
|
||||
.Ar directory
|
||||
|
|
Loading…
Reference in a new issue