Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d30bb669e | ||
|
|
ab6f5c21c8 | ||
|
|
4fc2ed32d2 | ||
|
|
00ab4f2a7d | ||
|
|
cb5d8b405b | ||
|
|
7b28aa8500 | ||
|
|
97a369df0a | ||
|
|
73a817c1cb | ||
|
|
c16053f0e5 |
@@ -1194,11 +1194,11 @@ namespace v2rayN.Handler
|
|||||||
}
|
}
|
||||||
if (isSub)
|
if (isSub)
|
||||||
{
|
{
|
||||||
SqliteHelper.Instance.Execute($"delete from ProfileItem where isSub = 1 and subid = {subid}");
|
SqliteHelper.Instance.Execute($"delete from ProfileItem where isSub = 1 and subid = '{subid}'");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SqliteHelper.Instance.Execute($"delete from ProfileItem where subid = {subid}");
|
SqliteHelper.Instance.Execute($"delete from ProfileItem where subid = '{subid}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace v2rayN.Handler
|
|||||||
where 1=1 ";
|
where 1=1 ";
|
||||||
if (!Utils.IsNullOrEmpty(subid))
|
if (!Utils.IsNullOrEmpty(subid))
|
||||||
{
|
{
|
||||||
sql += $" and a.subid = {subid}";
|
sql += $" and a.subid = '{subid}'";
|
||||||
}
|
}
|
||||||
if (!Utils.IsNullOrEmpty(filter))
|
if (!Utils.IsNullOrEmpty(filter))
|
||||||
{
|
{
|
||||||
@@ -134,11 +134,6 @@ namespace v2rayN.Handler
|
|||||||
return SqliteHelper.Instance.ExecuteAsync(sql);
|
return SqliteHelper.Instance.ExecuteAsync(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ServerStatItem> ServerStatItems()
|
|
||||||
{
|
|
||||||
return SqliteHelper.Instance.Table<ServerStatItem>().ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RoutingItem> RoutingItems()
|
public List<RoutingItem> RoutingItems()
|
||||||
{
|
{
|
||||||
return SqliteHelper.Instance.Table<RoutingItem>().Where(it => it.locked == false).ToList();
|
return SqliteHelper.Instance.Table<RoutingItem>().Where(it => it.locked == false).ToList();
|
||||||
|
|||||||
@@ -165,7 +165,6 @@ namespace v2rayN.Handler
|
|||||||
}
|
}
|
||||||
private async Task RunSpeedTestAsync()
|
private async Task RunSpeedTestAsync()
|
||||||
{
|
{
|
||||||
string testIndexId = string.Empty;
|
|
||||||
int pid = -1;
|
int pid = -1;
|
||||||
|
|
||||||
pid = _coreHandler.LoadCoreConfigString(_config, _selecteds);
|
pid = _coreHandler.LoadCoreConfigString(_config, _selecteds);
|
||||||
@@ -181,8 +180,6 @@ namespace v2rayN.Handler
|
|||||||
var timeout = 10;
|
var timeout = 10;
|
||||||
foreach (var it in _selecteds)
|
foreach (var it in _selecteds)
|
||||||
{
|
{
|
||||||
_ = LazyConfig.Instance.SetTestResult(it.indexId, "", "-1");
|
|
||||||
UpdateFunc(it.indexId, "", ResUI.Speedtesting);
|
|
||||||
if (!it.allowTest)
|
if (!it.allowTest)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -191,7 +188,8 @@ namespace v2rayN.Handler
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
testIndexId = it.indexId;
|
_ = LazyConfig.Instance.SetTestResult(it.indexId, "", "-1");
|
||||||
|
UpdateFunc(it.indexId, "", ResUI.Speedtesting);
|
||||||
|
|
||||||
var item = LazyConfig.Instance.GetProfileItem(it.indexId);
|
var item = LazyConfig.Instance.GetProfileItem(it.indexId);
|
||||||
if (item is null) continue;
|
if (item is null) continue;
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ namespace v2rayN.Handler
|
|||||||
private StatsService.StatsServiceClient client_;
|
private StatsService.StatsServiceClient client_;
|
||||||
private bool exitFlag_;
|
private bool exitFlag_;
|
||||||
private ServerStatItem _serverStatItem;
|
private ServerStatItem _serverStatItem;
|
||||||
|
private List<ServerStatItem> _lstServerStat;
|
||||||
|
public List<ServerStatItem> ServerStat => _lstServerStat;
|
||||||
|
|
||||||
Action<ServerSpeedItem> updateFunc_;
|
Action<ServerSpeedItem> updateFunc_;
|
||||||
|
|
||||||
@@ -83,11 +85,13 @@ namespace v2rayN.Handler
|
|||||||
GetServerStatItem(config_.indexId);
|
GetServerStatItem(config_.indexId);
|
||||||
ParseOutput(res.Stat, out ServerSpeedItem server);
|
ParseOutput(res.Stat, out ServerSpeedItem server);
|
||||||
|
|
||||||
|
if (server.proxyUp != 0 || server.proxyDown != 0)
|
||||||
|
{
|
||||||
_serverStatItem.todayUp += server.proxyUp;
|
_serverStatItem.todayUp += server.proxyUp;
|
||||||
_serverStatItem.todayDown += server.proxyDown;
|
_serverStatItem.todayDown += server.proxyDown;
|
||||||
_serverStatItem.totalUp += server.proxyUp;
|
_serverStatItem.totalUp += server.proxyUp;
|
||||||
_serverStatItem.totalDown += server.proxyDown;
|
_serverStatItem.totalDown += server.proxyDown;
|
||||||
|
}
|
||||||
if (Global.ShowInTaskbar)
|
if (Global.ShowInTaskbar)
|
||||||
{
|
{
|
||||||
server.indexId = config_.indexId;
|
server.indexId = config_.indexId;
|
||||||
@@ -97,11 +101,6 @@ namespace v2rayN.Handler
|
|||||||
server.totalDown = _serverStatItem.totalDown;
|
server.totalDown = _serverStatItem.totalDown;
|
||||||
updateFunc_(server);
|
updateFunc_(server);
|
||||||
}
|
}
|
||||||
if (server.proxyUp != 0 || server.proxyDown != 0)
|
|
||||||
{
|
|
||||||
_ = SqliteHelper.Instance.UpdateAsync(_serverStatItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var sleep = config_.statisticsFreshRate < 1 ? 1 : config_.statisticsFreshRate;
|
var sleep = config_.statisticsFreshRate < 1 ? 1 : config_.statisticsFreshRate;
|
||||||
@@ -118,12 +117,27 @@ namespace v2rayN.Handler
|
|||||||
{
|
{
|
||||||
SqliteHelper.Instance.Execute($"delete from ServerStatItem ");
|
SqliteHelper.Instance.Execute($"delete from ServerStatItem ");
|
||||||
_serverStatItem = null;
|
_serverStatItem = null;
|
||||||
|
_lstServerStat = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveTo()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SqliteHelper.Instance.UpdateAll(_lstServerStat);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Utils.SaveLog(ex.Message, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Init()
|
private void Init()
|
||||||
{
|
{
|
||||||
long ticks = DateTime.Now.Date.Ticks;
|
long ticks = DateTime.Now.Date.Ticks;
|
||||||
SqliteHelper.Instance.Execute($"update ServerStatItem set todayUp = 0,todayDown=0,dateNow={ticks} where dateNow<>{ticks}");
|
SqliteHelper.Instance.Execute($"update ServerStatItem set todayUp = 0,todayDown=0,dateNow={ticks} where dateNow<>{ticks}");
|
||||||
|
|
||||||
|
_lstServerStat = SqliteHelper.Instance.Table<ServerStatItem>().ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GetServerStatItem(string indexId)
|
private void GetServerStatItem(string indexId)
|
||||||
@@ -136,7 +150,7 @@ namespace v2rayN.Handler
|
|||||||
|
|
||||||
if (_serverStatItem == null)
|
if (_serverStatItem == null)
|
||||||
{
|
{
|
||||||
_serverStatItem = SqliteHelper.Instance.Table<ServerStatItem>().FirstOrDefault(t => t.indexId == indexId);
|
_serverStatItem = _lstServerStat.FirstOrDefault(t => t.indexId == indexId);
|
||||||
if (_serverStatItem == null)
|
if (_serverStatItem == null)
|
||||||
{
|
{
|
||||||
_serverStatItem = new ServerStatItem
|
_serverStatItem = new ServerStatItem
|
||||||
@@ -149,6 +163,7 @@ namespace v2rayN.Handler
|
|||||||
dateNow = ticks
|
dateNow = ticks
|
||||||
};
|
};
|
||||||
_ = SqliteHelper.Instance.Replacesync(_serverStatItem);
|
_ = SqliteHelper.Instance.Replacesync(_serverStatItem);
|
||||||
|
_lstServerStat.Add(_serverStatItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ namespace v2rayN.Base
|
|||||||
WorkingDirectory = Utils.GetConfigPath(),
|
WorkingDirectory = Utils.GetConfigPath(),
|
||||||
UseShellExecute = showWindow,
|
UseShellExecute = showWindow,
|
||||||
CreateNoWindow = !showWindow,
|
CreateNoWindow = !showWindow,
|
||||||
RedirectStandardError = !showWindow,
|
//RedirectStandardError = !showWindow,
|
||||||
Verb = "runas",
|
Verb = "runas",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -219,14 +219,14 @@ namespace v2rayN.Base
|
|||||||
_isRunning = true;
|
_isRunning = true;
|
||||||
if (p.WaitForExit(1000))
|
if (p.WaitForExit(1000))
|
||||||
{
|
{
|
||||||
if (showWindow)
|
//if (showWindow)
|
||||||
{
|
//{
|
||||||
throw new Exception("start tun mode fail");
|
throw new Exception("start tun mode fail");
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
throw new Exception(p.StandardError.ReadToEnd());
|
// throw new Exception(p.StandardError.ReadToEnd());
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
Global.processJob.AddProcess(p.Handle);
|
Global.processJob.AddProcess(p.Handle);
|
||||||
|
|||||||
@@ -278,6 +278,8 @@ namespace v2rayN.Handler
|
|||||||
string targetPath = Utils.GetBinPath($"{geoName}.dat", (ECoreType)Enum.Parse(typeof(ECoreType), it));
|
string targetPath = Utils.GetBinPath($"{geoName}.dat", (ECoreType)Enum.Parse(typeof(ECoreType), it));
|
||||||
File.Copy(fileName, targetPath, true);
|
File.Copy(fileName, targetPath, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
File.Delete(fileName);
|
||||||
//_updateFunc(true, "");
|
//_updateFunc(true, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
using Microsoft.Win32.TaskScheduler;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
@@ -601,13 +602,24 @@ namespace v2rayN
|
|||||||
|
|
||||||
//delete first
|
//delete first
|
||||||
RegWriteValue(Global.AutoRunRegPath, autoRunName, "");
|
RegWriteValue(Global.AutoRunRegPath, autoRunName, "");
|
||||||
|
if (IsAdministrator())
|
||||||
|
{
|
||||||
|
AutoStart(autoRunName, "", "");
|
||||||
|
}
|
||||||
|
|
||||||
if (run)
|
if (run)
|
||||||
{
|
{
|
||||||
string exePath = $"\"{GetExePath()}\"";
|
string exePath = $"\"{GetExePath()}\"";
|
||||||
|
if (IsAdministrator())
|
||||||
|
{
|
||||||
|
AutoStart(autoRunName, exePath, "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
RegWriteValue(Global.AutoRunRegPath, autoRunName, exePath);
|
RegWriteValue(Global.AutoRunRegPath, autoRunName, exePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
SaveLog(ex.Message, ex);
|
SaveLog(ex.Message, ex);
|
||||||
@@ -741,6 +753,47 @@ namespace v2rayN
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Auto Start via TaskService
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="taskName"></param>
|
||||||
|
/// <param name="fileName"></param>
|
||||||
|
/// <param name="description"></param>
|
||||||
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
|
public static void AutoStart(string taskName, string fileName, string description)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(taskName))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string TaskName = taskName;
|
||||||
|
var logonUser = WindowsIdentity.GetCurrent().Name;
|
||||||
|
string taskDescription = description;
|
||||||
|
string deamonFileName = fileName;
|
||||||
|
|
||||||
|
using (var taskService = new TaskService())
|
||||||
|
{
|
||||||
|
var tasks = taskService.RootFolder.GetTasks(new Regex(TaskName));
|
||||||
|
foreach (var t in tasks)
|
||||||
|
{
|
||||||
|
taskService.RootFolder.DeleteTask(t.Name);
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(fileName))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var task = taskService.NewTask();
|
||||||
|
task.RegistrationInfo.Description = taskDescription;
|
||||||
|
task.Settings.DisallowStartIfOnBatteries = false;
|
||||||
|
task.Triggers.Add(new LogonTrigger { UserId = logonUser, Delay = TimeSpan.FromMinutes(1) });
|
||||||
|
task.Principal.RunLevel = TaskRunLevel.Highest;
|
||||||
|
task.Actions.Add(new ExecAction(deamonFileName));
|
||||||
|
|
||||||
|
taskService.RootFolder.RegisterTaskDefinition(TaskName, task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 测速
|
#region 测速
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using ReactiveUI;
|
|||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Splat;
|
using Splat;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -637,6 +638,7 @@ namespace v2rayN.ViewModels
|
|||||||
SysProxyHandle.UpdateSysProxy(_config, true);
|
SysProxyHandle.UpdateSysProxy(_config, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_statistics?.SaveTo();
|
||||||
_statistics?.Close();
|
_statistics?.Close();
|
||||||
|
|
||||||
_coreHandler.CoreStop();
|
_coreHandler.CoreStop();
|
||||||
@@ -685,7 +687,7 @@ namespace v2rayN.ViewModels
|
|||||||
List<ServerStatItem> lstServerStat = new();
|
List<ServerStatItem> lstServerStat = new();
|
||||||
if (_statistics != null && _statistics.Enable)
|
if (_statistics != null && _statistics.Enable)
|
||||||
{
|
{
|
||||||
lstServerStat = LazyConfig.Instance.ServerStatItems();
|
lstServerStat = _statistics.ServerStat;
|
||||||
}
|
}
|
||||||
lstModel = (from t in lstModel
|
lstModel = (from t in lstModel
|
||||||
join t2 in lstServerStat
|
join t2 in lstServerStat
|
||||||
@@ -1284,6 +1286,11 @@ namespace v2rayN.ViewModels
|
|||||||
Reload();
|
Reload();
|
||||||
|
|
||||||
_noticeHandler?.SendMessage(ResUI.MsgUpdateV2rayCoreSuccessfully);
|
_noticeHandler?.SendMessage(ResUI.MsgUpdateV2rayCoreSuccessfully);
|
||||||
|
|
||||||
|
if (File.Exists(fileName))
|
||||||
|
{
|
||||||
|
File.Delete(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
(new UpdateHandle()).CheckUpdateCore(type, _config, _updateUI, _config.checkPreReleaseUpdate);
|
(new UpdateHandle()).CheckUpdateCore(type, _config, _updateUI, _config.checkPreReleaseUpdate);
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Splat;
|
using Splat;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Drawing;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Controls.Primitives;
|
using System.Windows.Controls.Primitives;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Interop;
|
||||||
using v2rayN.Handler;
|
using v2rayN.Handler;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
using v2rayN.Resx;
|
using v2rayN.Resx;
|
||||||
@@ -372,18 +374,21 @@ namespace v2rayN.Views
|
|||||||
{
|
{
|
||||||
if (_config.uiItem.mainWidth > 0 && _config.uiItem.mainHeight > 0)
|
if (_config.uiItem.mainWidth > 0 && _config.uiItem.mainHeight > 0)
|
||||||
{
|
{
|
||||||
if (_config.uiItem.mainWidth > SystemInformation.WorkingArea.Width)
|
Width = _config.uiItem.mainWidth;
|
||||||
{
|
Height = _config.uiItem.mainHeight;
|
||||||
_config.uiItem.mainWidth = SystemInformation.WorkingArea.Width * 2 / 3;
|
|
||||||
}
|
|
||||||
if (_config.uiItem.mainHeight > SystemInformation.WorkingArea.Height)
|
|
||||||
{
|
|
||||||
_config.uiItem.mainHeight = SystemInformation.WorkingArea.Height * 2 / 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Width = _config.uiItem.mainWidth;
|
IntPtr hWnd = new WindowInteropHelper(this).EnsureHandle();
|
||||||
this.Height = _config.uiItem.mainHeight;
|
Graphics g = Graphics.FromHwnd(hWnd);
|
||||||
|
if (Width > SystemInformation.WorkingArea.Width * 96 / g.DpiX)
|
||||||
|
{
|
||||||
|
Width = SystemInformation.WorkingArea.Width * 96 / g.DpiX;
|
||||||
}
|
}
|
||||||
|
if (Height > SystemInformation.WorkingArea.Height * 96 / g.DpiY)
|
||||||
|
{
|
||||||
|
Height = SystemInformation.WorkingArea.Height * 96 / g.DpiY;
|
||||||
|
}
|
||||||
|
|
||||||
for (int k = 0; k < lstProfiles.Columns.Count; k++)
|
for (int k = 0; k < lstProfiles.Columns.Count; k++)
|
||||||
{
|
{
|
||||||
var width = ConfigHandler.GetformMainLvColWidth(ref _config, ((EServerColName)k).ToString(), Convert.ToInt32(lstProfiles.Columns[k].Width.Value));
|
var width = ConfigHandler.GetformMainLvColWidth(ref _config, ((EServerColName)k).ToString(), Convert.ToInt32(lstProfiles.Columns[k].Width.Value));
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<ApplicationIcon>v2rayN.ico</ApplicationIcon>
|
<ApplicationIcon>v2rayN.ico</ApplicationIcon>
|
||||||
<Copyright>Copyright © 2017-2023 (GPLv3)</Copyright>
|
<Copyright>Copyright © 2017-2023 (GPLv3)</Copyright>
|
||||||
<FileVersion>6.2</FileVersion>
|
<FileVersion>6.3</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user