save bandwidth in config file per shadowsocks server
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user