mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-19 21:52:25 +00:00
commit
a3f42e1e25
5 changed files with 45 additions and 52 deletions
|
@ -59,25 +59,25 @@ namespace v2rayN.Forms
|
||||||
Utils.HumanFy(down)
|
Utils.HumanFy(down)
|
||||||
);
|
);
|
||||||
|
|
||||||
List<string[]> datas = new List<string[]>();
|
List<string[]> datas = new List<string[]>();
|
||||||
for (int i = 0; i < config.vmess.Count; i++)
|
for (int i = 0; i < config.vmess.Count; i++)
|
||||||
{
|
{
|
||||||
string totalUp_ = string.Empty,
|
string totalUp_ = string.Empty,
|
||||||
totalDown_ = string.Empty,
|
totalDown_ = string.Empty,
|
||||||
todayUp_ = string.Empty,
|
todayUp_ = string.Empty,
|
||||||
todayDown_ = 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));
|
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)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
totalUp_ = Utils.HumanFy(statistics[index].totalUp);
|
totalUp_ = Utils.HumanFy(statistics[index].totalUp);
|
||||||
totalDown_ = Utils.HumanFy(statistics[index].totalDown);
|
totalDown_ = Utils.HumanFy(statistics[index].totalDown);
|
||||||
todayUp_ = Utils.HumanFy(statistics[index].todayUp);
|
todayUp_ = Utils.HumanFy(statistics[index].todayUp);
|
||||||
todayDown_ = Utils.HumanFy(statistics[index].todayDown);
|
todayDown_ = Utils.HumanFy(statistics[index].todayDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
datas.Add(new string[] { totalUp_, totalDown_, todayUp_, todayDown_ });
|
datas.Add(new string[] { totalUp_, totalDown_, todayUp_, todayDown_ });
|
||||||
}
|
}
|
||||||
|
|
||||||
lvServers.Invoke((MethodInvoker)delegate
|
lvServers.Invoke((MethodInvoker)delegate
|
||||||
{
|
{
|
||||||
lvServers.SuspendLayout();
|
lvServers.SuspendLayout();
|
||||||
|
|
|
@ -30,8 +30,6 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
public bool UpdateUI;
|
public bool UpdateUI;
|
||||||
|
|
||||||
private StringBuilder outputBuilder_;
|
|
||||||
|
|
||||||
public ulong TotalUp { get; private set; }
|
public ulong TotalUp { get; private set; }
|
||||||
|
|
||||||
public ulong TotalDown { get; private set; }
|
public ulong TotalDown { get; private set; }
|
||||||
|
@ -59,14 +57,12 @@ namespace v2rayN.Handler
|
||||||
DeleteExpiredLog();
|
DeleteExpiredLog();
|
||||||
foreach (var server in config.vmess)
|
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);
|
Statistic.Add(statistic);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadFromFile();
|
loadFromFile();
|
||||||
|
|
||||||
outputBuilder_ = new StringBuilder();
|
|
||||||
|
|
||||||
var fullPath = Utils.GetPath(cliName_);
|
var fullPath = Utils.GetPath(cliName_);
|
||||||
|
|
||||||
if (!File.Exists(fullPath))
|
if (!File.Exists(fullPath))
|
||||||
|
@ -212,7 +208,7 @@ namespace v2rayN.Handler
|
||||||
overallWriter.WriteLine($"DOWN {string.Format("{0:f2}", down_amount)}{down_unit} {TotalDown}");
|
overallWriter.WriteLine($"DOWN {string.Format("{0:f2}", down_amount)}{down_unit} {TotalDown}");
|
||||||
foreach(var s in Statistic)
|
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()}");
|
dailyWriter.WriteLine($"LastUpdate {DateTime.Now.ToLongDateString()} {DateTime.Now.ToLongTimeString()}");
|
||||||
foreach (var s in Statistic)
|
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("*"))
|
else if (line.StartsWith("*"))
|
||||||
{
|
{
|
||||||
var datas = line.Split(' ');
|
var datas = line.Split(' ');
|
||||||
if (datas.Length < 6) return;
|
if (datas.Length < 8) return;
|
||||||
var name = datas[1];
|
var name = datas[1];
|
||||||
var address = datas[2];
|
var address = datas[2];
|
||||||
var port = int.Parse(datas[3]);
|
var port = int.Parse(datas[3]);
|
||||||
var path = datas[4];
|
var path = datas[4];
|
||||||
var totalUp = ulong.Parse(datas[5]);
|
var host = datas[5];
|
||||||
var totalDown = ulong.Parse(datas[6]);
|
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)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
Statistic[index].totalUp = totalUp;
|
Statistic[index].totalUp = totalUp;
|
||||||
|
@ -295,7 +293,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
else
|
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);
|
Statistic.Add(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,15 +321,17 @@ namespace v2rayN.Handler
|
||||||
else if (line.StartsWith("*"))
|
else if (line.StartsWith("*"))
|
||||||
{
|
{
|
||||||
var datas = line.Split(' ');
|
var datas = line.Split(' ');
|
||||||
if (datas.Length < 6) return;
|
if (datas.Length < 8) return;
|
||||||
var name = datas[1];
|
var name = datas[1];
|
||||||
var address = datas[2];
|
var address = datas[2];
|
||||||
var port = int.Parse(datas[3]);
|
var port = int.Parse(datas[3]);
|
||||||
var path = datas[4];
|
var path = datas[4];
|
||||||
var todayUp = ulong.Parse(datas[5]);
|
var host = datas[5];
|
||||||
var todayDown = ulong.Parse(datas[6]);
|
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)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
Statistic[index].todayUp = todayUp;
|
Statistic[index].todayUp = todayUp;
|
||||||
|
@ -339,7 +339,7 @@ namespace v2rayN.Handler
|
||||||
}
|
}
|
||||||
else
|
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);
|
Statistic.Add(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,18 +12,20 @@ namespace v2rayN.Mode
|
||||||
public string address;
|
public string address;
|
||||||
public int port;
|
public int port;
|
||||||
public string path;
|
public string path;
|
||||||
|
public string host;
|
||||||
public ulong totalUp;
|
public ulong totalUp;
|
||||||
public ulong totalDown;
|
public ulong totalDown;
|
||||||
public ulong todayUp;
|
public ulong todayUp;
|
||||||
public ulong todayDown;
|
public ulong todayDown;
|
||||||
|
|
||||||
public ServerStatistics() { }
|
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.name = name;
|
||||||
this.address = addr;
|
this.address = addr;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
|
this.host = host;
|
||||||
this.totalUp = totalUp;
|
this.totalUp = totalUp;
|
||||||
this.totalDown = totalDown;
|
this.totalDown = totalDown;
|
||||||
this.todayUp = todayUp;
|
this.todayUp = todayUp;
|
||||||
|
|
|
@ -29,24 +29,6 @@ namespace v2rayN
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
|
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();
|
Process instance = RunningInstance();
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
{
|
{
|
||||||
|
@ -62,7 +44,7 @@ namespace v2rayN
|
||||||
}
|
}
|
||||||
else
|
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);
|
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
|
#endregion
|
||||||
|
|
||||||
#region 开机自动启动
|
#region 开机自动启动
|
||||||
|
|
Loading…
Reference in a new issue