mirror of https://github.com/2dust/v2rayN
commit
a3f42e1e25
|
@ -59,25 +59,25 @@ namespace v2rayN.Forms
|
|||
Utils.HumanFy(down)
|
||||
);
|
||||
|
||||
List<string[]> datas = new List<string[]>();
|
||||
for (int i = 0; i < config.vmess.Count; i++)
|
||||
{
|
||||
string totalUp_ = string.Empty,
|
||||
totalDown_ = string.Empty,
|
||||
todayUp_ = string.Empty,
|
||||
todayDown_ = string.Empty;
|
||||
var index = statistics.FindIndex(item_ => (config.vmess[i].address == item_.address && config.vmess[i].port == item_.port && config.vmess[i].path == item_.path));
|
||||
if (index != -1)
|
||||
{
|
||||
totalUp_ = Utils.HumanFy(statistics[index].totalUp);
|
||||
totalDown_ = Utils.HumanFy(statistics[index].totalDown);
|
||||
todayUp_ = Utils.HumanFy(statistics[index].todayUp);
|
||||
todayDown_ = Utils.HumanFy(statistics[index].todayDown);
|
||||
List<string[]> datas = new List<string[]>();
|
||||
for (int i = 0; i < config.vmess.Count; i++)
|
||||
{
|
||||
string totalUp_ = string.Empty,
|
||||
totalDown_ = string.Empty,
|
||||
todayUp_ = string.Empty,
|
||||
todayDown_ = string.Empty;
|
||||
var index = statistics.FindIndex(item_ => Utils.IsIdenticalServer(item_, new ServerStatistics(config.vmess[i].remarks, config.vmess[i].address, config.vmess[i].port, config.vmess[i].path, config.vmess[i].requestHost, 0, 0, 0, 0)));
|
||||
if (index != -1)
|
||||
{
|
||||
totalUp_ = Utils.HumanFy(statistics[index].totalUp);
|
||||
totalDown_ = Utils.HumanFy(statistics[index].totalDown);
|
||||
todayUp_ = Utils.HumanFy(statistics[index].todayUp);
|
||||
todayDown_ = Utils.HumanFy(statistics[index].todayDown);
|
||||
}
|
||||
|
||||
datas.Add(new string[] { totalUp_, totalDown_, todayUp_, todayDown_ });
|
||||
}
|
||||
|
||||
|
||||
lvServers.Invoke((MethodInvoker)delegate
|
||||
{
|
||||
lvServers.SuspendLayout();
|
||||
|
|
|
@ -30,8 +30,6 @@ namespace v2rayN.Handler
|
|||
|
||||
public bool UpdateUI;
|
||||
|
||||
private StringBuilder outputBuilder_;
|
||||
|
||||
public ulong TotalUp { get; private set; }
|
||||
|
||||
public ulong TotalDown { get; private set; }
|
||||
|
@ -59,14 +57,12 @@ namespace v2rayN.Handler
|
|||
DeleteExpiredLog();
|
||||
foreach (var server in config.vmess)
|
||||
{
|
||||
var statistic = new ServerStatistics(server.remarks, server.address, server.port, server.path, 0, 0, 0, 0);
|
||||
var statistic = new ServerStatistics(server.remarks, server.address, server.port, server.path, server.requestHost, 0, 0, 0, 0);
|
||||
Statistic.Add(statistic);
|
||||
}
|
||||
|
||||
loadFromFile();
|
||||
|
||||
outputBuilder_ = new StringBuilder();
|
||||
|
||||
var fullPath = Utils.GetPath(cliName_);
|
||||
|
||||
if (!File.Exists(fullPath))
|
||||
|
@ -212,7 +208,7 @@ namespace v2rayN.Handler
|
|||
overallWriter.WriteLine($"DOWN {string.Format("{0:f2}", down_amount)}{down_unit} {TotalDown}");
|
||||
foreach(var s in Statistic)
|
||||
{
|
||||
overallWriter.WriteLine($"* {s.name} {s.address} {s.port} {s.path} {s.totalUp} {s.totalDown}");
|
||||
overallWriter.WriteLine($"* {s.name} {s.address} {s.port} {s.path} {s.host} {s.totalUp} {s.totalDown}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +227,7 @@ namespace v2rayN.Handler
|
|||
dailyWriter.WriteLine($"LastUpdate {DateTime.Now.ToLongDateString()} {DateTime.Now.ToLongTimeString()}");
|
||||
foreach (var s in Statistic)
|
||||
{
|
||||
dailyWriter.WriteLine($"* {s.name} {s.address} {s.port} {s.path} {s.todayUp} {s.todayDown}");
|
||||
dailyWriter.WriteLine($"* {s.name} {s.address} {s.port} {s.path} {s.host} {s.todayUp} {s.todayDown}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -279,15 +275,17 @@ namespace v2rayN.Handler
|
|||
else if (line.StartsWith("*"))
|
||||
{
|
||||
var datas = line.Split(' ');
|
||||
if (datas.Length < 6) return;
|
||||
if (datas.Length < 8) return;
|
||||
var name = datas[1];
|
||||
var address = datas[2];
|
||||
var port = int.Parse(datas[3]);
|
||||
var path = datas[4];
|
||||
var totalUp = ulong.Parse(datas[5]);
|
||||
var totalDown = ulong.Parse(datas[6]);
|
||||
var host = datas[5];
|
||||
var totalUp = ulong.Parse(datas[6]);
|
||||
var totalDown = ulong.Parse(datas[7]);
|
||||
|
||||
var index = Statistic.FindIndex(item => item.address == address && item.port == port);
|
||||
var temp = new ServerStatistics(name, address, port, path, host, 0, 0, 0, 0);
|
||||
var index = Statistic.FindIndex(item => Utils.IsIdenticalServer(item, temp));
|
||||
if (index != -1)
|
||||
{
|
||||
Statistic[index].totalUp = totalUp;
|
||||
|
@ -295,7 +293,7 @@ namespace v2rayN.Handler
|
|||
}
|
||||
else
|
||||
{
|
||||
var s = new Mode.ServerStatistics(name, address, port, path, totalUp, totalDown, 0, 0);
|
||||
var s = new Mode.ServerStatistics(name, address, port, path, host, totalUp, totalDown, 0, 0);
|
||||
Statistic.Add(s);
|
||||
}
|
||||
}
|
||||
|
@ -323,15 +321,17 @@ namespace v2rayN.Handler
|
|||
else if (line.StartsWith("*"))
|
||||
{
|
||||
var datas = line.Split(' ');
|
||||
if (datas.Length < 6) return;
|
||||
if (datas.Length < 8) return;
|
||||
var name = datas[1];
|
||||
var address = datas[2];
|
||||
var port = int.Parse(datas[3]);
|
||||
var path = datas[4];
|
||||
var todayUp = ulong.Parse(datas[5]);
|
||||
var todayDown = ulong.Parse(datas[6]);
|
||||
var host = datas[5];
|
||||
var todayUp = ulong.Parse(datas[6]);
|
||||
var todayDown = ulong.Parse(datas[7]);
|
||||
|
||||
var index = Statistic.FindIndex(item => item.address == address && item.port == port);
|
||||
var temp = new ServerStatistics(name, address, port, path, host, 0, 0, 0, 0);
|
||||
var index = Statistic.FindIndex(item => Utils.IsIdenticalServer(item, temp));
|
||||
if (index != -1)
|
||||
{
|
||||
Statistic[index].todayUp = todayUp;
|
||||
|
@ -339,7 +339,7 @@ namespace v2rayN.Handler
|
|||
}
|
||||
else
|
||||
{
|
||||
var s = new Mode.ServerStatistics(name, address, port, path, 0, 0, todayUp, todayDown);
|
||||
var s = new Mode.ServerStatistics(name, address, port, path, host, 0, 0, todayUp, todayDown);
|
||||
Statistic.Add(s);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,18 +12,20 @@ namespace v2rayN.Mode
|
|||
public string address;
|
||||
public int port;
|
||||
public string path;
|
||||
public string host;
|
||||
public ulong totalUp;
|
||||
public ulong totalDown;
|
||||
public ulong todayUp;
|
||||
public ulong todayDown;
|
||||
|
||||
public ServerStatistics() { }
|
||||
public ServerStatistics(string name, string addr, int port, string path, ulong totalUp, ulong totalDown, ulong todayUp, ulong todayDown)
|
||||
public ServerStatistics(string name, string addr, int port, string path, string host, ulong totalUp, ulong totalDown, ulong todayUp, ulong todayDown)
|
||||
{
|
||||
this.name = name;
|
||||
this.address = addr;
|
||||
this.port = port;
|
||||
this.path = path;
|
||||
this.host = host;
|
||||
this.totalUp = totalUp;
|
||||
this.totalDown = totalDown;
|
||||
this.todayUp = todayUp;
|
||||
|
|
|
@ -29,24 +29,6 @@ namespace v2rayN
|
|||
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
|
||||
|
||||
|
||||
var args = Environment.GetCommandLineArgs();
|
||||
bool _isRestart = args.Length > 1 && args[1] == "/restart";
|
||||
if (_isRestart)
|
||||
{
|
||||
try
|
||||
{
|
||||
// get old process and wait UP TO 5 secs then give up!
|
||||
int _restartProcessId = int.Parse(args[2]);
|
||||
Process oldProcess = Process.GetProcessById(_restartProcessId);
|
||||
oldProcess.WaitForExit();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// the process did not exist - probably already closed!
|
||||
//TODO: --> LOG
|
||||
}
|
||||
}
|
||||
|
||||
Process instance = RunningInstance();
|
||||
if (instance == null)
|
||||
{
|
||||
|
@ -62,7 +44,7 @@ namespace v2rayN
|
|||
}
|
||||
else
|
||||
{
|
||||
UI.Show($"v2rayN is already running(v2rayN已经运行){args[1]} {args[2]}");
|
||||
UI.Show($"v2rayN is already running(v2rayN已经运行)");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -442,6 +442,15 @@ namespace v2rayN
|
|||
return Regex.IsMatch(input, pattern, RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
public static bool IsIdenticalServer(Mode.ServerStatistics a, Mode.ServerStatistics b)
|
||||
{
|
||||
return (a.address == b.address
|
||||
&& a.port == b.port
|
||||
&& a.path == b.path
|
||||
&& a.host == b.host
|
||||
);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 开机自动启动
|
||||
|
|
Loading…
Reference in New Issue