diff --git a/shadowsocks-csharp/Controller/ShadowsocksController.cs b/shadowsocks-csharp/Controller/ShadowsocksController.cs index c94cbe39..79ff929d 100644 --- a/shadowsocks-csharp/Controller/ShadowsocksController.cs +++ b/shadowsocks-csharp/Controller/ShadowsocksController.cs @@ -465,37 +465,19 @@ namespace Shadowsocks.Controller _config = Configuration.Load(); StatisticsConfiguration = StatisticsStrategyConfiguration.Load(); - if (privoxyRunner == null) - { - privoxyRunner = new PrivoxyRunner(); - } + privoxyRunner = privoxyRunner ?? new PrivoxyRunner(); - if (_pacDaemon == null) - { - _pacDaemon = new PACDaemon(); - _pacDaemon.PACFileChanged += PacDaemon_PACFileChanged; - _pacDaemon.UserRuleFileChanged += PacDaemon_UserRuleFileChanged; - } + _pacDaemon = _pacDaemon ?? new PACDaemon(); + _pacDaemon.PACFileChanged += PacDaemon_PACFileChanged; + _pacDaemon.UserRuleFileChanged += PacDaemon_UserRuleFileChanged; + _pacServer = _pacServer ?? new PACServer(_pacDaemon); - if (_pacServer == null) - { - _pacServer = new PACServer(_pacDaemon); - } - - if (gfwListUpdater == null) - { - gfwListUpdater = new GFWListUpdater(); - gfwListUpdater.UpdateCompleted += PacServer_PACUpdateCompleted; - gfwListUpdater.Error += PacServer_PACUpdateError; - } + gfwListUpdater = gfwListUpdater ?? new GFWListUpdater(); + gfwListUpdater.UpdateCompleted += PacServer_PACUpdateCompleted; + gfwListUpdater.Error += PacServer_PACUpdateError; availabilityStatistics.UpdateConfiguration(this); - - if (_listener != null) - { - _listener.Stop(); - } - + _listener?.Stop(); StopPlugins(); // don't put PrivoxyRunner.Start() before pacServer.Stop() @@ -506,10 +488,7 @@ namespace Shadowsocks.Controller try { var strategy = GetCurrentStrategy(); - if (strategy != null) - { - strategy.ReloadServers(); - } + strategy?.ReloadServers(); StartPlugin(); privoxyRunner.Start(_config); @@ -546,7 +525,6 @@ namespace Shadowsocks.Controller } ConfigChanged?.Invoke(this, new EventArgs()); - UpdateSystemProxy(); Utils.ReleaseMemory(true); }