Browse Source

cleaning in Configuration.cs

tags/4.2.0.0
Student Main 5 years ago
parent
commit
f6fcab40ad
No known key found for this signature in database GPG Key ID: AA78519C208C8742
1 changed files with 14 additions and 22 deletions
  1. +14
    -22
      shadowsocks-csharp/Model/Configuration.cs

+ 14
- 22
shadowsocks-csharp/Model/Configuration.cs View File

@@ -11,7 +11,7 @@ namespace Shadowsocks.Model
public class Configuration
{
[JsonIgnore]
private static Logger logger = LogManager.GetCurrentClassLogger();
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public string version;
@@ -24,16 +24,10 @@ namespace Shadowsocks.Model
public bool enabled;
public bool shareOverLan;
public bool isDefault;
// hidden
public bool isIPv6Enabled = false;
public int localPort;
public bool portableMode = true;
public bool showPluginOutput;
public string pacUrl;
// geosite config is hidden
public string geositeUrl;
public string geositeGroup = "geolocation-!cn";
public bool geositeBlacklistMode = true;
public bool useOnlinePac;
public bool secureLocalPac = true;
@@ -42,8 +36,13 @@ namespace Shadowsocks.Model
public bool checkPreRelease;
public bool isVerboseLogging;
// hidden config
public bool generateLegacyUrl = false;
// hidden options
public bool isIPv6Enabled = false; // for experimental ipv6 support
public bool generateLegacyUrl = false; // for pre-sip002 url compatibility
public string geositeUrl; // for custom geosite source (and rule group)
public string geositeGroup = "geolocation-!cn";
public bool geositeBlacklistMode = true;
//public NLogConfig.LogLevel logLevel;
public LogViewerConfig logViewer;
@@ -54,11 +53,10 @@ namespace Shadowsocks.Model
NLogConfig nLogConfig;
private static readonly string CONFIG_FILE = "gui-config.json";
private static readonly NLogConfig.LogLevel verboseLogLevel =
#if DEBUG
NLogConfig.LogLevel.Trace;
private static readonly NLogConfig.LogLevel verboseLogLevel = NLogConfig.LogLevel.Trace;
#else
NLogConfig.LogLevel.Debug;
private static readonly NLogConfig.LogLevel verboseLogLevel = NLogConfig.LogLevel.Debug;
#endif
@@ -200,9 +198,9 @@ namespace Shadowsocks.Model
sw.Flush();
}
try
{
// apply changs to NLog.config
config.nLogConfig.SetLogLevel(config.isVerboseLogging? verboseLogLevel : NLogConfig.LogLevel.Info);
{
// apply changes to NLog.config
config.nLogConfig.SetLogLevel(config.isVerboseLogging ? verboseLogLevel : NLogConfig.LogLevel.Info);
NLogConfig.SaveXML(config.nLogConfig);
}
catch (Exception e)
@@ -218,7 +216,7 @@ namespace Shadowsocks.Model
public static Server AddDefaultServerOrServer(Configuration config, Server server = null, int? index = null)
{
if (config != null && config.configs != null)
if (config?.configs != null)
{
server = (server ?? GetDefaultServer());
@@ -237,12 +235,6 @@ namespace Shadowsocks.Model
return new Server();
}
private static void Assert(bool condition)
{
if (!condition)
throw new Exception(I18N.GetString("assertion failure"));
}
public static void CheckPort(int port)
{
if (port <= 0 || port > 65535)


Loading…
Cancel
Save