Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60dc9e7d71 | ||
|
|
02f75f899f | ||
|
|
eda92b80e1 | ||
|
|
ccec6be210 | ||
|
|
01c059c4e3 | ||
|
|
a0e79f37bc |
@@ -1,4 +1,10 @@
|
||||
2.5 2015-07-11
|
||||
2.5.1 2015-07-26
|
||||
- Prevent HA from switching servers too frequently
|
||||
- Fix a problem that server settings can not be updated when using HA
|
||||
- Fix server port can't be 8123
|
||||
- Other minor fixes
|
||||
|
||||
2.5 2015-07-25
|
||||
- Support load balance
|
||||
- Support high availability
|
||||
|
||||
|
||||
@@ -83,6 +83,10 @@ namespace Shadowsocks.Controller
|
||||
public void CreateRemote()
|
||||
{
|
||||
Server server = controller.GetAServer(IStrategyCallerType.TCP, (IPEndPoint)connection.RemoteEndPoint);
|
||||
if (server == null || server.server == "")
|
||||
{
|
||||
throw new ArgumentException("No server configured");
|
||||
}
|
||||
this.encryptor = EncryptorFactory.GetEncryptor(server.method, server.password);
|
||||
this.server = server;
|
||||
}
|
||||
@@ -310,6 +314,7 @@ namespace Shadowsocks.Controller
|
||||
|
||||
StartConnect();
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
Logging.LogUsefulException(e);
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Shadowsocks.Controller
|
||||
public string LatestVersionURL;
|
||||
public event EventHandler NewVersionFound;
|
||||
|
||||
public const string Version = "2.5";
|
||||
public const string Version = "2.5.1";
|
||||
|
||||
public void CheckUpdate(Configuration config)
|
||||
{
|
||||
@@ -154,7 +154,7 @@ namespace Shadowsocks.Controller
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
Logging.Debug(ex.ToString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,10 @@ namespace Shadowsocks.Controller
|
||||
{
|
||||
return strategy.GetAServer(type, localIPEndPoint);
|
||||
}
|
||||
if (_config.index < 0)
|
||||
{
|
||||
_config.index = 0;
|
||||
}
|
||||
return GetCurrentServer();
|
||||
}
|
||||
|
||||
@@ -293,7 +297,8 @@ namespace Shadowsocks.Controller
|
||||
polipoRunner.Stop();
|
||||
try
|
||||
{
|
||||
foreach (var strategy in GetStrategies())
|
||||
var strategy = GetCurrentStrategy();
|
||||
if (strategy != null)
|
||||
{
|
||||
strategy.ReloadServers();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Shadowsocks.Controller.Strategy
|
||||
{
|
||||
class HighAvailabilityStrategy : IStrategy
|
||||
{
|
||||
protected Server _currentServer;
|
||||
protected ServerStatus _currentServer;
|
||||
protected Dictionary<Server, ServerStatus> _serverStatus;
|
||||
ShadowsocksController _controller;
|
||||
Random _random;
|
||||
@@ -67,6 +67,11 @@ namespace Shadowsocks.Controller.Strategy
|
||||
status.lastTimeDetectLatency = DateTime.Now;
|
||||
newServerStatus[server] = status;
|
||||
}
|
||||
else
|
||||
{
|
||||
// update settings for existing server
|
||||
newServerStatus[server].server = server;
|
||||
}
|
||||
}
|
||||
_serverStatus = newServerStatus;
|
||||
|
||||
@@ -79,7 +84,11 @@ namespace Shadowsocks.Controller.Strategy
|
||||
{
|
||||
ChooseNewServer();
|
||||
}
|
||||
return _currentServer;
|
||||
if (_currentServer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _currentServer.server;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +99,7 @@ namespace Shadowsocks.Controller.Strategy
|
||||
*/
|
||||
public void ChooseNewServer()
|
||||
{
|
||||
Server oldServer = _currentServer;
|
||||
ServerStatus oldServer = _currentServer;
|
||||
List<ServerStatus> servers = new List<ServerStatus>(_serverStatus.Values);
|
||||
DateTime now = DateTime.Now;
|
||||
foreach (var status in servers)
|
||||
@@ -120,12 +129,11 @@ namespace Shadowsocks.Controller.Strategy
|
||||
}
|
||||
if (max != null)
|
||||
{
|
||||
_currentServer = max.server;
|
||||
if (_currentServer != oldServer)
|
||||
if (_currentServer == null || max.score - _currentServer.score > 200)
|
||||
{
|
||||
Console.WriteLine("HA switching to server: {0}", _currentServer.FriendlyName());
|
||||
_currentServer = max;
|
||||
Console.WriteLine("HA switching to server: {0}", _currentServer.server.FriendlyName());
|
||||
}
|
||||
Logging.Debug(String.Format("choosing server: {0}", _currentServer.FriendlyName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,13 @@ namespace Shadowsocks.Model
|
||||
{
|
||||
config.localPort = 1080;
|
||||
}
|
||||
if (config.index == -1)
|
||||
{
|
||||
if (config.strategy == null)
|
||||
{
|
||||
config.index = 0;
|
||||
}
|
||||
}
|
||||
return config;
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -86,6 +93,13 @@ namespace Shadowsocks.Model
|
||||
{
|
||||
config.index = -1;
|
||||
}
|
||||
if (config.index == -1)
|
||||
{
|
||||
if (config.strategy == null)
|
||||
{
|
||||
config.index = 0;
|
||||
}
|
||||
}
|
||||
config.isDefault = false;
|
||||
try
|
||||
{
|
||||
@@ -121,6 +135,11 @@ namespace Shadowsocks.Model
|
||||
{
|
||||
throw new ArgumentException(I18N.GetString("Port out of range"));
|
||||
}
|
||||
}
|
||||
|
||||
public static void CheckLocalPort(int port)
|
||||
{
|
||||
CheckPort(port);
|
||||
if (port == 8123)
|
||||
{
|
||||
throw new ArgumentException(I18N.GetString("Port can't be 8123"));
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Shadowsocks.View
|
||||
};
|
||||
int localPort = int.Parse(ProxyPortTextBox.Text);
|
||||
Configuration.CheckServer(server);
|
||||
Configuration.CheckPort(localPort);
|
||||
Configuration.CheckLocalPort(localPort);
|
||||
_modifiedConfiguration.configs[_oldSelectedIndex] = server;
|
||||
_modifiedConfiguration.localPort = localPort;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user