(trunk rpc) add a method to make the daemon test & see if the incoming peer port is open
This commit is contained in:
parent
76f7e59a8c
commit
0727849c7f
|
@ -433,8 +433,16 @@
|
|||
|
||||
Method name: "blocklist-update"
|
||||
Request arguments: none
|
||||
Response arguments: "blocklist-size"
|
||||
|
||||
Response arguments: a number "blocklist-size"
|
||||
|
||||
4.4. Port Checking
|
||||
|
||||
This method tests to see if your incoming peer port is accessible
|
||||
from the outside world.
|
||||
|
||||
Method name: "port-test"
|
||||
Request arguments: none
|
||||
Response arguments: a bool, "port-is-open"
|
||||
|
||||
5.0. Protocol Versions
|
||||
|
||||
|
@ -487,6 +495,7 @@
|
|||
| | yes | torrent-get | new ids option "percentDone"
|
||||
| | yes | | new method "torrent-reannounce"
|
||||
| | yes | | new method "blocklist-update"
|
||||
| | yes | | new method "port-test"
|
||||
| | NO | torrent-get | removed arg "downloadLimitMode"
|
||||
| | NO | torrent-get | removed arg "uploadLimitMode"
|
||||
| | NO | session-get | renamed "pex-allowed" to "pex-enabled"
|
||||
|
|
|
@ -757,6 +757,48 @@ torrentSet( tr_session * session,
|
|||
****
|
||||
***/
|
||||
|
||||
static void
|
||||
portTested( tr_session * session UNUSED,
|
||||
long response_code,
|
||||
const void * response,
|
||||
size_t response_byte_count,
|
||||
void * user_data )
|
||||
{
|
||||
char result[1024];
|
||||
struct tr_rpc_idle_data * data = user_data;
|
||||
|
||||
if( response_code != 200 )
|
||||
{
|
||||
tr_snprintf( result, sizeof( result ), "http error %ld: %s",
|
||||
response_code, tr_webGetResponseStr( response_code ) );
|
||||
}
|
||||
else /* success */
|
||||
{
|
||||
const tr_bool isOpen = response_byte_count && *(char*)response == '1';
|
||||
tr_bencDictAddBool( data->args_out, "port-is-open", isOpen );
|
||||
tr_snprintf( result, sizeof( result ), "success" );
|
||||
}
|
||||
|
||||
tr_idle_function_done( data, result );
|
||||
}
|
||||
|
||||
static const char*
|
||||
portTest( tr_session * session,
|
||||
tr_benc * args_in UNUSED,
|
||||
tr_benc * args_out UNUSED,
|
||||
struct tr_rpc_idle_data * idle_data )
|
||||
{
|
||||
const int port = tr_sessionGetPeerPort( session );
|
||||
char * url = tr_strdup_printf( "http://portcheck.transmissionbt.com/%d", port );
|
||||
tr_webRun( session, url, NULL, portTest, idle_data );
|
||||
tr_free( url );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
||||
static void
|
||||
gotNewBlocklist( tr_session * session,
|
||||
long response_code,
|
||||
|
@ -1183,6 +1225,7 @@ static struct method
|
|||
}
|
||||
methods[] =
|
||||
{
|
||||
{ "port-test", FALSE, portTest },
|
||||
{ "blocklist-update", FALSE, blocklistUpdate },
|
||||
{ "session-get", TRUE, sessionGet },
|
||||
{ "session-set", TRUE, sessionSet },
|
||||
|
|
Loading…
Reference in New Issue