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)
|
||||
{
|
||||
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
|
||||
{
|
||||
SqliteHelper.Instance.Execute($"delete from ProfileItem where subid = {subid}");
|
||||
SqliteHelper.Instance.Execute($"delete from ProfileItem where subid = '{subid}'");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace v2rayN.Handler
|
||||
where 1=1 ";
|
||||
if (!Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
sql += $" and a.subid = {subid}";
|
||||
sql += $" and a.subid = '{subid}'";
|
||||
}
|
||||
if (!Utils.IsNullOrEmpty(filter))
|
||||
{
|
||||
@@ -134,11 +134,6 @@ namespace v2rayN.Handler
|
||||
return SqliteHelper.Instance.ExecuteAsync(sql);
|
||||
}
|
||||
|
||||
public List<ServerStatItem> ServerStatItems()
|
||||
{
|
||||
return SqliteHelper.Instance.Table<ServerStatItem>().ToList();
|
||||
}
|
||||
|
||||
public List<RoutingItem> RoutingItems()
|
||||
{
|
||||
return SqliteHelper.Instance.Table<RoutingItem>().Where(it => it.locked == false).ToList();
|
||||
|
||||
@@ -165,7 +165,6 @@ namespace v2rayN.Handler
|
||||
}
|
||||
private async Task RunSpeedTestAsync()
|
||||
{
|
||||
string testIndexId = string.Empty;
|
||||
int pid = -1;
|
||||
|
||||
pid = _coreHandler.LoadCoreConfigString(_config, _selecteds);
|
||||
@@ -181,8 +180,6 @@ namespace v2rayN.Handler
|
||||
var timeout = 10;
|
||||
foreach (var it in _selecteds)
|
||||
{
|
||||
_ = LazyConfig.Instance.SetTestResult(it.indexId, "", "-1");
|
||||
UpdateFunc(it.indexId, "", ResUI.Speedtesting);
|
||||
if (!it.allowTest)
|
||||
{
|
||||
continue;
|
||||
@@ -191,7 +188,8 @@ namespace v2rayN.Handler
|
||||
{
|
||||
continue;
|
||||
}
|
||||
testIndexId = it.indexId;
|
||||
_ = LazyConfig.Instance.SetTestResult(it.indexId, "", "-1");
|
||||
UpdateFunc(it.indexId, "", ResUI.Speedtesting);
|
||||
|
||||
var item = LazyConfig.Instance.GetProfileItem(it.indexId);
|
||||
if (item is null) continue;
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace v2rayN.Handler
|
||||
private StatsService.StatsServiceClient client_;
|
||||
private bool exitFlag_;
|
||||
private ServerStatItem _serverStatItem;
|
||||
private List<ServerStatItem> _lstServerStat;
|
||||
public List<ServerStatItem> ServerStat => _lstServerStat;
|
||||
|
||||
Action<ServerSpeedItem> updateFunc_;
|
||||
|
||||
@@ -83,11 +85,13 @@ namespace v2rayN.Handler
|
||||
GetServerStatItem(config_.indexId);
|
||||
ParseOutput(res.Stat, out ServerSpeedItem server);
|
||||
|
||||
_serverStatItem.todayUp += server.proxyUp;
|
||||
_serverStatItem.todayDown += server.proxyDown;
|
||||
_serverStatItem.totalUp += server.proxyUp;
|
||||
_serverStatItem.totalDown += server.proxyDown;
|
||||
|
||||
if (server.proxyUp != 0 || server.proxyDown != 0)
|
||||
{
|
||||
_serverStatItem.todayUp += server.proxyUp;
|
||||
_serverStatItem.todayDown += server.proxyDown;
|
||||
_serverStatItem.totalUp += server.proxyUp;
|
||||
_serverStatItem.totalDown += server.proxyDown;
|
||||
}
|
||||
if (Global.ShowInTaskbar)
|
||||
{
|
||||
server.indexId = config_.indexId;
|
||||
@@ -97,11 +101,6 @@ namespace v2rayN.Handler
|
||||
server.totalDown = _serverStatItem.totalDown;
|
||||
updateFunc_(server);
|
||||
}
|
||||
if (server.proxyUp != 0 || server.proxyDown != 0)
|
||||
{
|
||||
_ = SqliteHelper.Instance.UpdateAsync(_serverStatItem);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
var sleep = config_.statisticsFreshRate < 1 ? 1 : config_.statisticsFreshRate;
|
||||
@@ -118,12 +117,27 @@ namespace v2rayN.Handler
|
||||
{
|
||||
SqliteHelper.Instance.Execute($"delete from ServerStatItem ");
|
||||
_serverStatItem = null;
|
||||
_lstServerStat = new();
|
||||
}
|
||||
|
||||
public void SaveTo()
|
||||
{
|
||||
try
|
||||
{
|
||||
SqliteHelper.Instance.UpdateAll(_lstServerStat);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utils.SaveLog(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
long ticks = DateTime.Now.Date.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)
|
||||
@@ -136,7 +150,7 @@ namespace v2rayN.Handler
|
||||
|
||||
if (_serverStatItem == null)
|
||||
{
|
||||
_serverStatItem = SqliteHelper.Instance.Table<ServerStatItem>().FirstOrDefault(t => t.indexId == indexId);
|
||||
_serverStatItem = _lstServerStat.FirstOrDefault(t => t.indexId == indexId);
|
||||
if (_serverStatItem == null)
|
||||
{
|
||||
_serverStatItem = new ServerStatItem
|
||||
@@ -149,6 +163,7 @@ namespace v2rayN.Handler
|
||||
dateNow = ticks
|
||||
};
|
||||
_ = SqliteHelper.Instance.Replacesync(_serverStatItem);
|
||||
_lstServerStat.Add(_serverStatItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace v2rayN.Base
|
||||
WorkingDirectory = Utils.GetConfigPath(),
|
||||
UseShellExecute = showWindow,
|
||||
CreateNoWindow = !showWindow,
|
||||
RedirectStandardError = !showWindow,
|
||||
//RedirectStandardError = !showWindow,
|
||||
Verb = "runas",
|
||||
}
|
||||
};
|
||||
@@ -219,14 +219,14 @@ namespace v2rayN.Base
|
||||
_isRunning = true;
|
||||
if (p.WaitForExit(1000))
|
||||
{
|
||||
if (showWindow)
|
||||
{
|
||||
throw new Exception("start tun mode fail");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(p.StandardError.ReadToEnd());
|
||||
}
|
||||
//if (showWindow)
|
||||
//{
|
||||
throw new Exception("start tun mode fail");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// throw new Exception(p.StandardError.ReadToEnd());
|
||||
//}
|
||||
}
|
||||
|
||||
Global.processJob.AddProcess(p.Handle);
|
||||
|
||||
@@ -278,6 +278,8 @@ namespace v2rayN.Handler
|
||||
string targetPath = Utils.GetBinPath($"{geoName}.dat", (ECoreType)Enum.Parse(typeof(ECoreType), it));
|
||||
File.Copy(fileName, targetPath, true);
|
||||
});
|
||||
|
||||
File.Delete(fileName);
|
||||
//_updateFunc(true, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Win32;
|
||||
using Microsoft.Win32.TaskScheduler;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
@@ -601,11 +602,22 @@ namespace v2rayN
|
||||
|
||||
//delete first
|
||||
RegWriteValue(Global.AutoRunRegPath, autoRunName, "");
|
||||
if (IsAdministrator())
|
||||
{
|
||||
AutoStart(autoRunName, "", "");
|
||||
}
|
||||
|
||||
if (run)
|
||||
{
|
||||
string exePath = $"\"{GetExePath()}\"";
|
||||
RegWriteValue(Global.AutoRunRegPath, autoRunName, exePath);
|
||||
if (IsAdministrator())
|
||||
{
|
||||
AutoStart(autoRunName, exePath, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
RegWriteValue(Global.AutoRunRegPath, autoRunName, exePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -740,6 +752,47 @@ namespace v2rayN
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using System.Text;
|
||||
@@ -226,7 +227,7 @@ namespace v2rayN.ViewModels
|
||||
this.WhenAnyValue(
|
||||
x => x.SelectedMoveToGroup,
|
||||
y => y != null && !y.remarks.IsNullOrEmpty())
|
||||
.Subscribe(c => MoveToGroup(c));
|
||||
.Subscribe(c => MoveToGroup(c));
|
||||
|
||||
this.WhenAnyValue(
|
||||
x => x.SelectedRouting,
|
||||
@@ -637,6 +638,7 @@ namespace v2rayN.ViewModels
|
||||
SysProxyHandle.UpdateSysProxy(_config, true);
|
||||
}
|
||||
|
||||
_statistics?.SaveTo();
|
||||
_statistics?.Close();
|
||||
|
||||
_coreHandler.CoreStop();
|
||||
@@ -685,7 +687,7 @@ namespace v2rayN.ViewModels
|
||||
List<ServerStatItem> lstServerStat = new();
|
||||
if (_statistics != null && _statistics.Enable)
|
||||
{
|
||||
lstServerStat = LazyConfig.Instance.ServerStatItems();
|
||||
lstServerStat = _statistics.ServerStat;
|
||||
}
|
||||
lstModel = (from t in lstModel
|
||||
join t2 in lstServerStat
|
||||
@@ -1284,6 +1286,11 @@ namespace v2rayN.ViewModels
|
||||
Reload();
|
||||
|
||||
_noticeHandler?.SendMessage(ResUI.MsgUpdateV2rayCoreSuccessfully);
|
||||
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
File.Delete(fileName);
|
||||
}
|
||||
}
|
||||
};
|
||||
(new UpdateHandle()).CheckUpdateCore(type, _config, _updateUI, _config.checkPreReleaseUpdate);
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using ReactiveUI;
|
||||
using Splat;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using v2rayN.Handler;
|
||||
using v2rayN.Mode;
|
||||
using v2rayN.Resx;
|
||||
@@ -372,18 +374,21 @@ namespace v2rayN.Views
|
||||
{
|
||||
if (_config.uiItem.mainWidth > 0 && _config.uiItem.mainHeight > 0)
|
||||
{
|
||||
if (_config.uiItem.mainWidth > SystemInformation.WorkingArea.Width)
|
||||
{
|
||||
_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;
|
||||
this.Height = _config.uiItem.mainHeight;
|
||||
Width = _config.uiItem.mainWidth;
|
||||
Height = _config.uiItem.mainHeight;
|
||||
}
|
||||
|
||||
IntPtr hWnd = new WindowInteropHelper(this).EnsureHandle();
|
||||
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++)
|
||||
{
|
||||
var width = ConfigHandler.GetformMainLvColWidth(ref _config, ((EServerColName)k).ToString(), Convert.ToInt32(lstProfiles.Columns[k].Width.Value));
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace v2rayN.Views
|
||||
private void LstSubscription_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ViewModel?.EditSub(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void menuClose_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<ApplicationIcon>v2rayN.ico</ApplicationIcon>
|
||||
<Copyright>Copyright © 2017-2023 (GPLv3)</Copyright>
|
||||
<FileVersion>6.2</FileVersion>
|
||||
<FileVersion>6.3</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user