Merge remote-tracking branch 'upstream/master' into feature/statistics_ui
This commit is contained in:
@@ -123,16 +123,18 @@ namespace Shadowsocks.Controller
|
||||
{
|
||||
Logging.Debug("Ping " + server.FriendlyName());
|
||||
if (server.server == "") return null;
|
||||
var IP = Dns.GetHostAddresses(server.server).First(ip => (ip.AddressFamily == AddressFamily.InterNetwork || ip.AddressFamily == AddressFamily.InterNetworkV6));
|
||||
var ping = new Ping();
|
||||
var ret = new List<DataList>();
|
||||
foreach (var timestamp in Enumerable.Range(0, Repeat).Select(_ => DateTime.Now.ToString(DateTimePattern)))
|
||||
{
|
||||
//ICMP echo. we can also set options and special bytes
|
||||
try
|
||||
try {
|
||||
var IP = Dns.GetHostAddresses(server.server).First(ip => (ip.AddressFamily == AddressFamily.InterNetwork || ip.AddressFamily == AddressFamily.InterNetworkV6));
|
||||
var ping = new Ping();
|
||||
|
||||
foreach (var timestamp in Enumerable.Range(0, Repeat).Select(_ => DateTime.Now.ToString(DateTimePattern)))
|
||||
{
|
||||
var reply = await ping.SendTaskAsync(IP, Timeout);
|
||||
ret.Add(new List<KeyValuePair<string, string>>
|
||||
//ICMP echo. we can also set options and special bytes
|
||||
try
|
||||
{
|
||||
var reply = await ping.SendTaskAsync(IP, Timeout);
|
||||
ret.Add(new List<KeyValuePair<string, string>>
|
||||
{
|
||||
new KeyValuePair<string, string>("Timestamp", timestamp),
|
||||
new KeyValuePair<string, string>("Server", server.FriendlyName()),
|
||||
@@ -143,14 +145,19 @@ namespace Shadowsocks.Controller
|
||||
new KeyValuePair<string, string>("OutboundSpeed", GetRecentOutboundSpeed(server))
|
||||
//new KeyValuePair<string, string>("data", reply.Buffer.ToString()); // The data of reply
|
||||
});
|
||||
Thread.Sleep(Timeout + new Random().Next() % Timeout);
|
||||
//Do ICMPTest in a random frequency
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logging.Error($"An exception occured while eveluating {server.FriendlyName()}");
|
||||
Logging.LogUsefulException(e);
|
||||
Thread.Sleep(Timeout + new Random().Next() % Timeout);
|
||||
//Do ICMPTest in a random frequency
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logging.Error($"An exception occured while eveluating {server.FriendlyName()}");
|
||||
Logging.LogUsefulException(e);
|
||||
}
|
||||
}
|
||||
}catch(Exception e)
|
||||
{
|
||||
Logging.Error($"An exception occured while eveluating {server.FriendlyName()}");
|
||||
Logging.LogUsefulException(e);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -269,9 +276,20 @@ namespace Shadowsocks.Controller
|
||||
Logging.Debug($"loading statistics from {path}");
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Console.WriteLine($"statistics file does not exist, try to reload {RetryInterval.TotalMinutes} minutes later");
|
||||
_timer.Change(RetryInterval, Interval);
|
||||
return;
|
||||
try {
|
||||
using (FileStream fs = File.Create(path))
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
}catch(Exception e)
|
||||
{
|
||||
Logging.LogUsefulException(e);
|
||||
}
|
||||
if (!File.Exists(path)) {
|
||||
Console.WriteLine($"statistics file does not exist, try to reload {RetryInterval / 60 / 1000} minutes later");
|
||||
_timer.Change(RetryInterval, Interval);
|
||||
return;
|
||||
}
|
||||
}
|
||||
RawStatistics = (from l in File.ReadAllLines(path).Skip(1)
|
||||
let strings = l.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
|
||||
|
||||
@@ -10,6 +10,7 @@ PAC=PAC 模式
|
||||
Global=全局模式
|
||||
Servers=服务器
|
||||
Edit Servers...=编辑服务器...
|
||||
Statistics Config...=统计配置...
|
||||
Start on Boot=开机启动
|
||||
Allow Clients from LAN=允许来自局域网的连接
|
||||
Local PAC=使用本地 PAC
|
||||
|
||||
Reference in New Issue
Block a user