diff --git a/shadowsocks-csharp/Controller/Service/PACServer.cs b/shadowsocks-csharp/Controller/Service/PACServer.cs index 5db8b64a..c6853331 100644 --- a/shadowsocks-csharp/Controller/Service/PACServer.cs +++ b/shadowsocks-csharp/Controller/Service/PACServer.cs @@ -147,7 +147,7 @@ Connection: Close ", Encoding.UTF8.GetBytes(pac).Length) + pac; byte[] response = Encoding.UTF8.GetBytes(text); socket.BeginSend(response, 0, response.Length, 0, new AsyncCallback(SendCallback), socket); - Util.Utils.ReleaseMemory(true); + Utils.ReleaseMemory(true); } catch (Exception e) { diff --git a/shadowsocks-csharp/Controller/ShadowsocksController.cs b/shadowsocks-csharp/Controller/ShadowsocksController.cs index 9ddce8ca..356f58cb 100755 --- a/shadowsocks-csharp/Controller/ShadowsocksController.cs +++ b/shadowsocks-csharp/Controller/ShadowsocksController.cs @@ -63,8 +63,8 @@ namespace Shadowsocks.Controller public ShadowsocksController() { _config = Configuration.Load(); - inboundCounter = _config.bandwidthIn; - outboundCounter = _config.bandwidthOut; + inboundCounter = _config.GetCurrentServer().bandwidthIn; + outboundCounter = _config.GetCurrentServer().bandwidthOut; StatisticsConfiguration = StatisticsStrategyConfiguration.Load(); _strategyManager = new StrategyManager(this); StartReleasingMemory(); @@ -312,21 +312,21 @@ namespace Shadowsocks.Controller public void UpdateInboundCounter(long n) { Interlocked.Add(ref inboundCounter, n); - _config.bandwidthIn = inboundCounter; + _config.GetCurrentServer().bandwidthIn = inboundCounter; } public void UpdateOutboundCounter(long n) { Interlocked.Add(ref outboundCounter, n); - _config.bandwidthOut = outboundCounter; + _config.GetCurrentServer().bandwidthOut = outboundCounter; } protected void Reload() { // some logic in configuration updated the config when saving, we need to read it again _config = Configuration.Load(); - inboundCounter = _config.bandwidthIn; - outboundCounter = _config.bandwidthOut; + inboundCounter = _config.GetCurrentServer().bandwidthIn; + outboundCounter = _config.GetCurrentServer().bandwidthOut; StatisticsConfiguration = StatisticsStrategyConfiguration.Load(); if (polipoRunner == null) @@ -404,7 +404,7 @@ namespace Shadowsocks.Controller } UpdateSystemProxy(); - Util.Utils.ReleaseMemory(true); + Utils.ReleaseMemory(true); } protected void SaveConfig(Configuration newConfig) @@ -500,7 +500,7 @@ namespace Shadowsocks.Controller { while (true) { - Util.Utils.ReleaseMemory(false); + Utils.ReleaseMemory(false); Thread.Sleep(30 * 1000); } } diff --git a/shadowsocks-csharp/Model/Configuration.cs b/shadowsocks-csharp/Model/Configuration.cs index b97cad03..d65c23a9 100755 --- a/shadowsocks-csharp/Model/Configuration.cs +++ b/shadowsocks-csharp/Model/Configuration.cs @@ -25,8 +25,6 @@ namespace Shadowsocks.Model public bool availabilityStatistics; public bool autoCheckUpdate; public LogViewerConfig logViewer; - public long bandwidthIn; - public long bandwidthOut; private static string CONFIG_FILE = "gui-config.json"; diff --git a/shadowsocks-csharp/Model/Server.cs b/shadowsocks-csharp/Model/Server.cs index 8306d9e3..4ae22fde 100755 --- a/shadowsocks-csharp/Model/Server.cs +++ b/shadowsocks-csharp/Model/Server.cs @@ -15,6 +15,8 @@ namespace Shadowsocks.Model public string method; public string remarks; public bool auth; + public long bandwidthIn; + public long bandwidthOut; public override int GetHashCode() { diff --git a/shadowsocks-csharp/View/MenuViewController.cs b/shadowsocks-csharp/View/MenuViewController.cs index 435f55ca..32eb992d 100755 --- a/shadowsocks-csharp/View/MenuViewController.cs +++ b/shadowsocks-csharp/View/MenuViewController.cs @@ -11,6 +11,7 @@ using ZXing.QrCode; using Shadowsocks.Controller; using Shadowsocks.Model; using Shadowsocks.Properties; +using Shadowsocks.Util; namespace Shadowsocks.View { @@ -387,7 +388,7 @@ namespace Shadowsocks.View void configForm_FormClosed(object sender, FormClosedEventArgs e) { configForm = null; - Util.Utils.ReleaseMemory(true); + Utils.ReleaseMemory(true); ShowFirstTimeBalloon(); }