mirror of
https://github.com/transmission/transmission
synced 2024-12-24 08:43:27 +00:00
(trunk daemon) added --dump option to dump the settings to stderr and exit.
This commit is contained in:
parent
d52631cb67
commit
e56643d7e7
2 changed files with 15 additions and 2 deletions
|
@ -53,6 +53,7 @@ static const struct tr_option options[] =
|
|||
{ 'a', "allowed", "Allowed IP addresses. (Default: " TR_DEFAULT_RPC_WHITELIST ")", "a", 1, "<list>" },
|
||||
{ 'b', "blocklist", "Enable peer blocklists", "b", 0, NULL },
|
||||
{ 'B', "no-blocklist", "Disable peer blocklists", "B", 0, NULL },
|
||||
{ 'd', "dump-settings", "Dump the settings and exit", "d", 0, NULL },
|
||||
{ 'f', "foreground", "Run in the foreground instead of daemonizing", "f", 0, NULL },
|
||||
{ 'g', "config-dir", "Where to look for configuration files", "g", 1, "<path>" },
|
||||
{ 'p', "port", "RPC port (Default: " TR_DEFAULT_RPC_PORT_STR ")", "p", 1, "<port>" },
|
||||
|
@ -180,9 +181,11 @@ main( int argc,
|
|||
char ** argv )
|
||||
{
|
||||
int c;
|
||||
int64_t i;
|
||||
const char * optarg;
|
||||
tr_benc settings;
|
||||
tr_bool foreground = FALSE;
|
||||
tr_bool dumpSettings = FALSE;
|
||||
const char * configDir = NULL;
|
||||
|
||||
signal( SIGINT, gotsig );
|
||||
|
@ -209,6 +212,8 @@ main( int argc,
|
|||
break;
|
||||
case 'B': tr_bencDictAddInt( &settings, TR_PREFS_KEY_BLOCKLIST_ENABLED, 0 );
|
||||
break;
|
||||
case 'd': dumpSettings = TRUE;
|
||||
break;
|
||||
case 'f': foreground = TRUE;
|
||||
break;
|
||||
case 'g': /* handled above */
|
||||
|
@ -230,6 +235,14 @@ main( int argc,
|
|||
}
|
||||
}
|
||||
|
||||
if( dumpSettings )
|
||||
{
|
||||
char * str = tr_bencSaveAsJSON( &settings, NULL );
|
||||
fprintf( stderr, "%s", str );
|
||||
tr_free( str );
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
if( !foreground )
|
||||
{
|
||||
|
@ -244,7 +257,7 @@ main( int argc,
|
|||
/* start the session */
|
||||
mySession = tr_sessionInit( "daemon", configDir, FALSE, &settings );
|
||||
|
||||
if( tr_bencDictFindInt( &settings, TR_PREFS_KEY_RPC_AUTH_REQUIRED, NULL ) )
|
||||
if( tr_bencDictFindInt( &settings, TR_PREFS_KEY_RPC_AUTH_REQUIRED, &i ) && i!=0 )
|
||||
tr_ninf( MY_NAME, "requiring authentication" );
|
||||
|
||||
/* load the torrents */
|
||||
|
|
|
@ -339,7 +339,7 @@ tr_sessionSaveSettings( tr_session * session, const char * configDir, tr_benc *
|
|||
tr_bencFree( &fileSettings );
|
||||
}
|
||||
|
||||
tr_inf( "saved \"%s\"", filename );
|
||||
tr_inf( "Saved \"%s\"", filename );
|
||||
tr_free( filename );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue