1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-20 13:16:53 +00:00

senseless RPC changes

This commit is contained in:
Charles Kerr 2008-06-18 22:01:15 +00:00
parent abf1349f91
commit 509dbaae3d
4 changed files with 58 additions and 15 deletions

View file

@ -348,7 +348,7 @@ processRequests( const char * host, int port,
int i;
CURL * curl;
struct evbuffer * buf = evbuffer_new( );
char * url = tr_strdup_printf( "http://%s:%d/transmission", host, port );
char * url = tr_strdup_printf( "http://%s:%d/transmission/rpc", host, port );
curl = curl_easy_init( );
curl_easy_setopt( curl, CURLOPT_VERBOSE, debug );

View file

@ -21,7 +21,7 @@
2.1. Requests
Requests supports three keys:
Requests support three keys:
(1) A required "method" string telling the name of the method to invoke
(2) An optional "arguments" object of key/value pairs
@ -80,13 +80,13 @@
string | value type & description
---------------------------+-------------------------------------------------
"files-wanted" | array indices of one or more file to download
"files-unwanted" | array indices of one or more file to not download
"ids" | array which torrent(s) to set, described in 3.1
"files-wanted" | array indices of file(s) to download
"files-unwanted" | array indices of file(s) to not download
"ids" | array torrent list, as described in 3.1
"peer-limit" | number maximum number of peers
"priority-high" | array indices of one or more high-priority files
"priority-low" | array indices of one or more low-priority files
"priority-normal" | array indices of one or more normal-priority files
"priority-high" | array indices of high-priority file(s)
"priority-low" | array indices of low-priority file(s)
"priority-normal" | array indices of normal-priority file(s)
"speed-limit-down" | number maximum download speed (in KiB/s)
"speed-limit-down-enabled" | 'boolean' true if the download speed is limited
"speed-limit-up" | number maximum upload speed (in KiB/s)
@ -294,7 +294,8 @@
form of one of 3.3's tr_info objects with the
fields for id, name, and hashString.
4. Session Status Requests
4. Session Requests
4.1. Session Arguments
@ -311,15 +312,32 @@
"speed-limit-up" | number max global upload speed (in KiB/s)
"speed-limit-up-enabled" | 'boolean' true means enabled
4.2. Mutators
4.1.1. Mutators
Method name: "session-set"
Request arguments: one or more of 4.1's arguments
Response arguments: none
4.2. Accessors
4.1.2. Accessors
Method name: "session-get"
Request arguments: none
Response arguments: all of 4.1's arguments
4.2. Session Statistics
Method name: "session-stats"
Request arguments: none
Response arguments:
string | value type
---------------------------+-------------------------------------------------
"activeTorrentCount" | number
"downloadSpeed" | number
"pausedTorrentCount" | number
"torrentCount" | number
"uploadSpeed" | number

View file

@ -152,7 +152,7 @@ startServer( tr_rpc_server * server )
server->ctx = shttpd_init( );
snprintf( ports, sizeof( ports ), "%d", server->port );
shttpd_register_uri( server->ctx, "/transmission", handle_rpc, server );
shttpd_register_uri( server->ctx, "/transmission/rpc", handle_rpc, server );
shttpd_set_option( server->ctx, "ports", ports );
shttpd_set_option( server->ctx, "dir_list", "0" );
shttpd_set_option( server->ctx, "root", "/dev/null" );
@ -162,7 +162,7 @@ startServer( tr_rpc_server * server )
shttpd_set_option( server->ctx, "acl", server->acl );
}
if( server->isPasswordEnabled ) {
char * buf = tr_strdup_printf( "/transmission=%s", passwd );
char * buf = tr_strdup_printf( "/transmission/rpc=%s", passwd );
shttpd_set_option( server->ctx, "protect", buf );
tr_free( buf );
}

View file

@ -248,8 +248,8 @@ addInfo( const tr_torrent * tor, tr_benc * d, uint64_t fields )
tr_bencDictAddInt( d, "peersConnected", st->peersConnected );
tr_bencDictAddInt( d, "peersGettingFromUs", st->peersGettingFromUs );
tr_bencDictAddInt( d, "peersSendingToUs", st->peersSendingToUs );
tr_bencDictAddDouble( d, "rateDownload", st->rateDownload );
tr_bencDictAddDouble( d, "rateUpload", st->rateUpload );
tr_bencDictAddInt( d, "rateDownload", (int)(st->rateDownload*1024) );
tr_bencDictAddInt( d, "rateUpload", (int)(st->rateUpload*1024) );
tr_bencDictAddDouble( d, "recheckProgress", st->recheckProgress );
tr_bencDictAddInt( d, "status", st->status );
tr_bencDictAddDouble( d, "swarmSpeed", st->swarmSpeed );
@ -554,6 +554,30 @@ sessionSet( tr_handle * h, tr_benc * args_in, tr_benc * args_out UNUSED )
return NULL;
}
static const char*
sessionStats( tr_handle * h, tr_benc * args_in UNUSED, tr_benc * args_out )
{
tr_benc * d = tr_bencDictAddDict( args_out, "session-stats", 10 );
tr_torrent * tor = NULL;
float up, down;
int running = 0;
int total = 0;
tr_sessionGetSpeed( h, &down, &up );
while(( tor = tr_torrentNext( h, tor ))) {
++total;
if( tor->isRunning )
++running;
}
tr_bencDictAddInt( d, "activeTorrentCount", running );
tr_bencDictAddInt( d, "downloadSpeed", (int)(down*1024) );
tr_bencDictAddInt( d, "pausedTorrentCount", total-running );
tr_bencDictAddInt( d, "torrentCount", total );
tr_bencDictAddInt( d, "uploadSpeed", (int)(up*1024) );
return NULL;
}
static const char*
sessionGet( tr_handle * h, tr_benc * args_in UNUSED, tr_benc * args_out )
{
@ -602,6 +626,7 @@ struct method {
} methods[] = {
{ "session-get", sessionGet },
{ "session-set", sessionSet },
{ "session-stats", sessionStats },
{ "torrent-add", torrentAdd },
{ "torrent-get", torrentGet },
{ "torrent-remove", torrentRemove },