Browse Source

save bandwidth in config file per shadowsocks server

tags/3.0
kimw 8 years ago
parent
commit
1ee07d196a
5 changed files with 13 additions and 12 deletions
  1. +1
    -1
      shadowsocks-csharp/Controller/Service/PACServer.cs
  2. +8
    -8
      shadowsocks-csharp/Controller/ShadowsocksController.cs
  3. +0
    -2
      shadowsocks-csharp/Model/Configuration.cs
  4. +2
    -0
      shadowsocks-csharp/Model/Server.cs
  5. +2
    -1
      shadowsocks-csharp/View/MenuViewController.cs

+ 1
- 1
shadowsocks-csharp/Controller/Service/PACServer.cs View File

@@ -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)
{


+ 8
- 8
shadowsocks-csharp/Controller/ShadowsocksController.cs View File

@@ -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);
}
}


+ 0
- 2
shadowsocks-csharp/Model/Configuration.cs View File

@@ -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";


+ 2
- 0
shadowsocks-csharp/Model/Server.cs View File

@@ -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()
{


+ 2
- 1
shadowsocks-csharp/View/MenuViewController.cs View File

@@ -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();
}


Loading…
Cancel
Save