@ -10,6 +10,7 @@ using NzbDrone.Common.Cache;
using NzbDrone.Common.Disk ;
using NzbDrone.Common.EnvironmentInfo ;
using NzbDrone.Common.Extensions ;
using NzbDrone.Common.Options ;
using NzbDrone.Core.Authentication ;
using NzbDrone.Core.Configuration.Events ;
using NzbDrone.Core.Datastore ;
@ -71,6 +72,11 @@ namespace NzbDrone.Core.Configuration
private readonly IDiskProvider _diskProvider ;
private readonly ICached < string > _cache ;
private readonly PostgresOptions _postgresOptions ;
private readonly AuthOptions _authOptions ;
private readonly AppOptions _appOptions ;
private readonly ServerOptions _serverOptions ;
private readonly UpdateOptions _updateOptions ;
private readonly LogOptions _logOptions ;
private readonly string _configFile ;
private static readonly Regex HiddenCharacterRegex = new Regex ( "[^a-z0-9]" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
@ -81,13 +87,23 @@ namespace NzbDrone.Core.Configuration
ICacheManager cacheManager ,
IEventAggregator eventAggregator ,
IDiskProvider diskProvider ,
IOptions < PostgresOptions > postgresOptions )
IOptions < PostgresOptions > postgresOptions ,
IOptions < AuthOptions > authOptions ,
IOptions < AppOptions > appOptions ,
IOptions < ServerOptions > serverOptions ,
IOptions < UpdateOptions > updateOptions ,
IOptions < LogOptions > logOptions )
{
_cache = cacheManager . GetCache < string > ( GetType ( ) ) ;
_eventAggregator = eventAggregator ;
_diskProvider = diskProvider ;
_configFile = appFolderInfo . GetConfigPath ( ) ;
_postgresOptions = postgresOptions . Value ;
_authOptions = authOptions . Value ;
_appOptions = appOptions . Value ;
_serverOptions = serverOptions . Value ;
_updateOptions = updateOptions . Value ;
_logOptions = logOptions . Value ;
}
public Dictionary < string , object > GetConfigDictionary ( )
@ -143,7 +159,7 @@ namespace NzbDrone.Core.Configuration
{
const string defaultValue = "*" ;
var bindAddress = GetValue( "BindAddress" , defaultValue ) ;
var bindAddress = _serverOptions. BindAddress ? ? GetValue( "BindAddress" , defaultValue ) ;
if ( string . IsNullOrWhiteSpace ( bindAddress ) )
{
return defaultValue ;
@ -153,19 +169,19 @@ namespace NzbDrone.Core.Configuration
}
}
public int Port = > GetValueInt( "Port" , 7878 ) ;
public int Port = > _serverOptions. Port ? ? GetValueInt( "Port" , 7878 ) ;
public int SslPort = > GetValueInt( "SslPort" , 9898 ) ;
public int SslPort = > _serverOptions. SslPort ? ? GetValueInt( "SslPort" , 9898 ) ;
public bool EnableSsl = > GetValueBoolean( "EnableSsl" , false ) ;
public bool EnableSsl = > _serverOptions. EnableSsl ? ? GetValueBoolean( "EnableSsl" , false ) ;
public bool LaunchBrowser = > GetValueBoolean( "LaunchBrowser" , true ) ;
public bool LaunchBrowser = > _appOptions. LaunchBrowser ? ? GetValueBoolean( "LaunchBrowser" , true ) ;
public string ApiKey
{
get
{
var apiKey = GetValue( "ApiKey" , GenerateApiKey ( ) ) ;
var apiKey = _authOptions. ApiKey ? ? GetValue( "ApiKey" , GenerateApiKey ( ) ) ;
if ( apiKey . IsNullOrWhiteSpace ( ) )
{
@ -181,7 +197,7 @@ namespace NzbDrone.Core.Configuration
{
get
{
var enabled = GetValueBoolean( "AuthenticationEnabled" , false , false ) ;
var enabled = _authOptions. Enabled ? ? GetValueBoolean( "AuthenticationEnabled" , false , false ) ;
if ( enabled )
{
@ -189,36 +205,41 @@ namespace NzbDrone.Core.Configuration
return AuthenticationType . Basic ;
}
return GetValueEnum ( "AuthenticationMethod" , AuthenticationType . None ) ;
return Enum . TryParse < AuthenticationType > ( _authOptions . Method , out var enumValue )
? enumValue
: GetValueEnum ( "AuthenticationMethod" , AuthenticationType . None ) ;
}
}
public AuthenticationRequiredType AuthenticationRequired = > GetValueEnum ( "AuthenticationRequired" , AuthenticationRequiredType . Enabled ) ;
public AuthenticationRequiredType AuthenticationRequired = >
Enum . TryParse < AuthenticationRequiredType > ( _authOptions . Required , out var enumValue )
? enumValue
: GetValueEnum ( "AuthenticationRequired" , AuthenticationRequiredType . Enabled ) ;
public bool AnalyticsEnabled = > GetValueBoolean ( "AnalyticsEnabled" , true , persist : false ) ;
public bool AnalyticsEnabled = > _logOptions. AnalyticsEnabled ? ? GetValueBoolean( "AnalyticsEnabled" , true , persist : false ) ;
public string Branch = > GetValue( "Branch" , "master" ) . ToLowerInvariant ( ) ;
public string Branch = > _updateOptions. Branch ? ? GetValue( "Branch" , "master" ) . ToLowerInvariant ( ) ;
public string LogLevel = > GetValue( "LogLevel" , "info" ) . ToLowerInvariant ( ) ;
public string ConsoleLogLevel = > GetValue( "ConsoleLogLevel" , string . Empty , persist : false ) ;
public string Theme = > GetValue( "Theme" , "auto" , persist : false ) ;
public string LogLevel = > _logOptions. Level ? ? GetValue( "LogLevel" , "info" ) . ToLowerInvariant ( ) ;
public string ConsoleLogLevel = > _logOptions. ConsoleLevel ? ? GetValue( "ConsoleLogLevel" , string . Empty , persist : false ) ;
public string Theme = > _appOptions. Theme ? ? GetValue( "Theme" , "auto" , persist : false ) ;
public string PostgresHost = > _postgresOptions ? . Host ? ? GetValue ( "PostgresHost" , string . Empty , persist : false ) ;
public string PostgresUser = > _postgresOptions ? . User ? ? GetValue ( "PostgresUser" , string . Empty , persist : false ) ;
public string PostgresPassword = > _postgresOptions ? . Password ? ? GetValue ( "PostgresPassword" , string . Empty , persist : false ) ;
public string PostgresMainDb = > _postgresOptions ? . MainDb ? ? GetValue ( "PostgresMainDb" , "radarr-main" , persist : false ) ;
public string PostgresLogDb = > _postgresOptions ? . LogDb ? ? GetValue ( "PostgresLogDb" , "radarr-log" , persist : false ) ;
public int PostgresPort = > ( _postgresOptions ? . Port ? ? 0 ) ! = 0 ? _postgresOptions . Port : GetValueInt ( "PostgresPort" , 5432 , persist : false ) ;
public bool LogSql = > GetValueBoolean( "LogSql" , false , persist : false ) ;
public int LogRotate = > GetValueInt( "LogRotate" , 50 , persist : false ) ;
public bool FilterSentryEvents = > GetValueBoolean( "FilterSentryEvents" , true , persist : false ) ;
public string SslCertPath = > GetValue( "SslCertPath" , "" ) ;
public string SslCertPassword = > GetValue( "SslCertPassword" , "" ) ;
public bool LogSql = > _logOptions. Sql ? ? GetValueBoolean( "LogSql" , false , persist : false ) ;
public int LogRotate = > _logOptions. Rotate ? ? GetValueInt( "LogRotate" , 50 , persist : false ) ;
public bool FilterSentryEvents = > _logOptions. FilterSentryEvents ? ? GetValueBoolean( "FilterSentryEvents" , true , persist : false ) ;
public string SslCertPath = > _serverOptions. SslCertPath ? ? GetValue( "SslCertPath" , "" ) ;
public string SslCertPassword = > _serverOptions. SslCertPassword ? ? GetValue( "SslCertPassword" , "" ) ;
public string UrlBase
{
get
{
var urlBase = GetValue( "UrlBase" , "" ) . Trim ( '/' ) ;
var urlBase = _serverOptions. UrlBase ? ? GetValue( "UrlBase" , "" ) . Trim ( '/' ) ;
if ( urlBase . IsNullOrWhiteSpace ( ) )
{
@ -230,19 +251,22 @@ namespace NzbDrone.Core.Configuration
}
public string UiFolder = > BuildInfo . IsDebug ? Path . Combine ( ".." , "UI" ) : "UI" ;
public string InstanceName = > GetValue( "InstanceName" , BuildInfo . AppName ) ;
public string InstanceName = > _appOptions. InstanceName ? ? GetValue( "InstanceName" , BuildInfo . AppName ) ;
public bool UpdateAutomatically = > GetValueBoolean( "UpdateAutomatically" , false , false ) ;
public bool UpdateAutomatically = > _updateOptions. Automatically ? ? GetValueBoolean( "UpdateAutomatically" , false , false ) ;
public UpdateMechanism UpdateMechanism = > GetValueEnum ( "UpdateMechanism" , UpdateMechanism . BuiltIn , false ) ;
public UpdateMechanism UpdateMechanism = >
Enum . TryParse < UpdateMechanism > ( _updateOptions . Mechanism , out var enumValue )
? enumValue
: GetValueEnum ( "UpdateMechanism" , UpdateMechanism . BuiltIn , false ) ;
public string UpdateScriptPath = > GetValue ( "UpdateScriptPath" , "" , false ) ;
public string UpdateScriptPath = > _updateOptions. ScriptPath ? ? GetValue( "UpdateScriptPath" , "" , false ) ;
public string SyslogServer = > GetValue( "SyslogServer" , "" , persist : false ) ;
public string SyslogServer = > _logOptions. SyslogServer ? ? GetValue( "SyslogServer" , "" , persist : false ) ;
public int SyslogPort = > GetValueInt( "SyslogPort" , 514 , persist : false ) ;
public int SyslogPort = > _logOptions. SyslogPort ? ? GetValueInt( "SyslogPort" , 514 , persist : false ) ;
public string SyslogLevel = > GetValue( "SyslogLevel" , LogLevel , false ) . ToLowerInvariant ( ) ;
public string SyslogLevel = > _logOptions. SyslogLevel ? ? GetValue( "SyslogLevel" , LogLevel , persist : false ) . ToLowerInvariant ( ) ;
public int GetValueInt ( string key , int defaultValue , bool persist = true )
{