Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9738f90970 | ||
|
|
6ed0741339 | ||
|
|
e6b1e22245 | ||
|
|
6b922be0c6 | ||
|
|
6e35a260e8 | ||
|
|
1106fd8cf1 | ||
|
|
fb92b90d5c | ||
|
|
5effbee50b |
@@ -19,18 +19,15 @@ namespace AmazTool
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Try to end the process(尝试结束进程).");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Process[] existing = Process.GetProcessesByName(V2rayN);
|
var path = GetPath(V2rayN);
|
||||||
foreach (Process p in existing)
|
Console.WriteLine(path);
|
||||||
{
|
var existing = Process.GetProcessesByName(V2rayN);
|
||||||
var path = p.MainModule?.FileName ?? "";
|
var pp = existing.FirstOrDefault(p => p.MainModule?.FileName != null && p.MainModule?.FileName == path);
|
||||||
if (path.StartsWith(GetPath(V2rayN)))
|
pp?.Kill();
|
||||||
{
|
pp?.WaitForExit(1000);
|
||||||
p.Kill();
|
|
||||||
p.WaitForExit(100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -39,6 +36,7 @@ namespace AmazTool
|
|||||||
"Close it manually, or the upgrade may fail.(请手动关闭正在运行的v2rayN,否则可能升级失败。\n\n" + ex.StackTrace);
|
"Close it manually, or the upgrade may fail.(请手动关闭正在运行的v2rayN,否则可能升级失败。\n\n" + ex.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Start extracting files(开始解压文件).");
|
||||||
StringBuilder sb = new();
|
StringBuilder sb = new();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -84,13 +82,12 @@ namespace AmazTool
|
|||||||
}
|
}
|
||||||
if (sb.Length > 0)
|
if (sb.Length > 0)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Upgrade Failed.\n" +
|
Console.WriteLine("Upgrade Failed(升级失败)." + sb.ToString());
|
||||||
"(升级失败)." + sb.ToString());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("Start v2rayN, please wait...(正在重启,请等待)");
|
Console.WriteLine("Start v2rayN, please wait...(正在重启,请等待)");
|
||||||
Thread.Sleep(3000);
|
Thread.Sleep(9000);
|
||||||
Process process = new()
|
Process process = new()
|
||||||
{
|
{
|
||||||
StartInfo = new()
|
StartInfo = new()
|
||||||
|
|||||||
@@ -159,7 +159,7 @@
|
|||||||
await ConfigHandler.SetDefaultServer(_config, lstModel);
|
await ConfigHandler.SetDefaultServer(_config, lstModel);
|
||||||
|
|
||||||
var lstServerStat = (_config.GuiItem.EnableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? [];
|
var lstServerStat = (_config.GuiItem.EnableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? [];
|
||||||
var lstProfileExs = ProfileExHandler.Instance.ProfileExs;
|
var lstProfileExs = await ProfileExHandler.Instance.GetProfileExs();
|
||||||
lstModel = (from t in lstModel
|
lstModel = (from t in lstModel
|
||||||
join t2 in lstServerStat on t.IndexId equals t2.IndexId into t2b
|
join t2 in lstServerStat on t.IndexId equals t2.IndexId into t2b
|
||||||
from t22 in t2b.DefaultIfEmpty()
|
from t22 in t2b.DefaultIfEmpty()
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace ServiceLib.Handler
|
|||||||
return new Tuple<ClashProxies, ClashProviders>(clashProxies, clashProviders);
|
return new Tuple<ClashProxies, ClashProviders>(clashProxies, clashProviders);
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.Delay(5000);
|
await Task.Delay(2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -746,7 +746,7 @@ namespace ServiceLib.Handler
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
var lstProfileExs = ProfileExHandler.Instance.ProfileExs;
|
var lstProfileExs = await ProfileExHandler.Instance.GetProfileExs();
|
||||||
var lstProfile = (from t in lstModel
|
var lstProfile = (from t in lstModel
|
||||||
join t3 in lstProfileExs on t.IndexId equals t3.IndexId into t3b
|
join t3 in lstProfileExs on t.IndexId equals t3.IndexId into t3b
|
||||||
from t33 in t3b.DefaultIfEmpty()
|
from t33 in t3b.DefaultIfEmpty()
|
||||||
|
|||||||
@@ -12,18 +12,12 @@
|
|||||||
|
|
||||||
if (node.ConfigType == EConfigType.Custom)
|
if (node.ConfigType == EConfigType.Custom)
|
||||||
{
|
{
|
||||||
if (node.CoreType is ECoreType.mihomo)
|
result = node.CoreType switch
|
||||||
{
|
{
|
||||||
result = await new CoreConfigClashService(config).GenerateClientCustomConfig(node, fileName);
|
ECoreType.mihomo => await new CoreConfigClashService(config).GenerateClientCustomConfig(node, fileName),
|
||||||
}
|
ECoreType.sing_box => await new CoreConfigSingboxService(config).GenerateClientCustomConfig(node, fileName),
|
||||||
if (node.CoreType is ECoreType.sing_box)
|
_ => await GenerateClientCustomConfig(node, fileName)
|
||||||
{
|
};
|
||||||
result = await new CoreConfigSingboxService(config).GenerateClientCustomConfig(node, fileName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = await GenerateClientCustomConfig(node, fileName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (AppHandler.Instance.GetCoreType(node, node.ConfigType) == ECoreType.sing_box)
|
else if (AppHandler.Instance.GetCoreType(node, node.ConfigType) == ECoreType.sing_box)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ namespace ServiceLib.Handler
|
|||||||
{
|
{
|
||||||
if (it.CoreType == ECoreType.v2rayN)
|
if (it.CoreType == ECoreType.v2rayN)
|
||||||
{
|
{
|
||||||
|
if (Utils.UpgradeAppExists(out var fileName))
|
||||||
|
{
|
||||||
|
await Utils.SetLinuxChmod(fileName);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,27 +9,31 @@ namespace ServiceLib.Handler
|
|||||||
private static readonly Lazy<ProfileExHandler> _instance = new(() => new());
|
private static readonly Lazy<ProfileExHandler> _instance = new(() => new());
|
||||||
private ConcurrentBag<ProfileExItem> _lstProfileEx = [];
|
private ConcurrentBag<ProfileExItem> _lstProfileEx = [];
|
||||||
private Queue<string> _queIndexIds = new();
|
private Queue<string> _queIndexIds = new();
|
||||||
public ConcurrentBag<ProfileExItem> ProfileExs => _lstProfileEx;
|
|
||||||
public static ProfileExHandler Instance => _instance.Value;
|
public static ProfileExHandler Instance => _instance.Value;
|
||||||
|
|
||||||
public ProfileExHandler()
|
public ProfileExHandler()
|
||||||
{
|
{
|
||||||
Init();
|
//Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Init()
|
public async Task Init()
|
||||||
{
|
{
|
||||||
await InitData();
|
await InitData();
|
||||||
await Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
await SaveQueueIndexIds();
|
|
||||||
await Task.Delay(1000 * 600);
|
await Task.Delay(1000 * 600);
|
||||||
|
await SaveQueueIndexIds();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<ConcurrentBag<ProfileExItem>> GetProfileExs()
|
||||||
|
{
|
||||||
|
return _lstProfileEx;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task InitData()
|
private async Task InitData()
|
||||||
{
|
{
|
||||||
await SQLiteHelper.Instance.ExecuteAsync($"delete from ProfileExItem where indexId not in ( select indexId from ProfileItem )");
|
await SQLiteHelper.Instance.ExecuteAsync($"delete from ProfileExItem where indexId not in ( select indexId from ProfileItem )");
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>7.0.1</Version>
|
<Version>7.0.2</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ namespace ServiceLib.ViewModels
|
|||||||
_checkUpdateItem.Clear();
|
_checkUpdateItem.Clear();
|
||||||
|
|
||||||
if (RuntimeInformation.ProcessArchitecture != Architecture.X86)
|
if (RuntimeInformation.ProcessArchitecture != Architecture.X86)
|
||||||
|
{
|
||||||
|
if (Utils.IsWindows())
|
||||||
{
|
{
|
||||||
_checkUpdateItem.Add(new CheckUpdateItem()
|
_checkUpdateItem.Add(new CheckUpdateItem()
|
||||||
{
|
{
|
||||||
@@ -51,6 +53,8 @@ namespace ServiceLib.ViewModels
|
|||||||
CoreType = _v2rayN,
|
CoreType = _v2rayN,
|
||||||
Remarks = ResUI.menuCheckUpdate,
|
Remarks = ResUI.menuCheckUpdate,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
_checkUpdateItem.Add(new CheckUpdateItem()
|
_checkUpdateItem.Add(new CheckUpdateItem()
|
||||||
{
|
{
|
||||||
IsSelected = true,
|
IsSelected = true,
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ namespace ServiceLib.ViewModels
|
|||||||
private async Task Init()
|
private async Task Init()
|
||||||
{
|
{
|
||||||
await ProxiesReload();
|
await ProxiesReload();
|
||||||
await DelayTestTask();
|
DelayTestTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DoRulemodeSelected(bool c)
|
private async Task DoRulemodeSelected(bool c)
|
||||||
@@ -434,24 +434,28 @@ namespace ServiceLib.ViewModels
|
|||||||
public async Task DelayTestTask()
|
public async Task DelayTestTask()
|
||||||
{
|
{
|
||||||
var lastTime = DateTime.Now;
|
var lastTime = DateTime.Now;
|
||||||
|
Task.Run(async () =>
|
||||||
Observable.Interval(TimeSpan.FromSeconds(60))
|
|
||||||
.Subscribe(async x =>
|
|
||||||
{
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
await Task.Delay(1000 * 60);
|
||||||
|
|
||||||
if (!(AutoRefresh && _config.UiItem.ShowInTaskbar && _config.IsRunningCore(ECoreType.sing_box)))
|
if (!(AutoRefresh && _config.UiItem.ShowInTaskbar && _config.IsRunningCore(ECoreType.sing_box)))
|
||||||
{
|
{
|
||||||
return;
|
continue;
|
||||||
|
}
|
||||||
|
if (_config.ClashUIItem.ProxiesAutoDelayTestInterval <= 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
var dtNow = DateTime.Now;
|
var dtNow = DateTime.Now;
|
||||||
if (_config.ClashUIItem.ProxiesAutoDelayTestInterval > 0)
|
if ((dtNow - lastTime).Minutes % _config.ClashUIItem.ProxiesAutoDelayTestInterval != 0)
|
||||||
{
|
|
||||||
if ((dtNow - lastTime).Minutes % _config.ClashUIItem.ProxiesAutoDelayTestInterval == 0)
|
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
await ProxiesDelayTest();
|
await ProxiesDelayTest();
|
||||||
lastTime = dtNow;
|
lastTime = dtNow;
|
||||||
}
|
}
|
||||||
Task.Delay(1000).Wait();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ namespace ServiceLib.ViewModels
|
|||||||
|
|
||||||
await ConfigHandler.InitBuiltinRouting(_config);
|
await ConfigHandler.InitBuiltinRouting(_config);
|
||||||
await ConfigHandler.InitBuiltinDNS(_config);
|
await ConfigHandler.InitBuiltinDNS(_config);
|
||||||
|
await ProfileExHandler.Instance.Init();
|
||||||
await CoreHandler.Instance.Init(_config, UpdateHandler);
|
await CoreHandler.Instance.Init(_config, UpdateHandler);
|
||||||
TaskHandler.Instance.RegUpdateTask(_config, UpdateTaskHandler);
|
TaskHandler.Instance.RegUpdateTask(_config, UpdateTaskHandler);
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,18 @@ namespace ServiceLib.ViewModels
|
|||||||
public StatusBarViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public StatusBarViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppHandler.Instance.Config;
|
||||||
|
SelectedRouting = new();
|
||||||
|
SelectedServer = new();
|
||||||
|
RunningServerToolTipText = "-";
|
||||||
|
|
||||||
|
if (_config.TunModeItem.EnableTun && AppHandler.Instance.IsAdministrator)
|
||||||
|
{
|
||||||
|
EnableTun = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_config.TunModeItem.EnableTun = EnableTun = false;
|
||||||
|
}
|
||||||
|
|
||||||
#region WhenAnyValue && ReactiveCommand
|
#region WhenAnyValue && ReactiveCommand
|
||||||
|
|
||||||
@@ -179,19 +191,6 @@ namespace ServiceLib.ViewModels
|
|||||||
|
|
||||||
private async Task Init()
|
private async Task Init()
|
||||||
{
|
{
|
||||||
SelectedRouting = new();
|
|
||||||
SelectedServer = new();
|
|
||||||
RunningServerToolTipText = "-";
|
|
||||||
|
|
||||||
if (_config.TunModeItem.EnableTun && AppHandler.Instance.IsAdministrator)
|
|
||||||
{
|
|
||||||
EnableTun = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_config.TunModeItem.EnableTun = EnableTun = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
await RefreshRoutingsMenu();
|
await RefreshRoutingsMenu();
|
||||||
await InboundDisplayStatus();
|
await InboundDisplayStatus();
|
||||||
await ChangeSystemProxyAsync(_config.SystemProxyItem.SysProxyType, true);
|
await ChangeSystemProxyAsync(_config.SystemProxyItem.SysProxyType, true);
|
||||||
|
|||||||
@@ -161,10 +161,7 @@
|
|||||||
<RowDefinition Height="8" />
|
<RowDefinition Height="8" />
|
||||||
<RowDefinition Height="1*" />
|
<RowDefinition Height="1*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<TextBlock
|
<TextBlock Grid.Row="0" Text="{Binding Name}" />
|
||||||
Grid.Row="0"
|
|
||||||
Text="{Binding Name}"
|
|
||||||
TextWrapping="WrapWithOverflow" />
|
|
||||||
<DockPanel Grid.Row="2">
|
<DockPanel Grid.Row="2">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
DockPanel.Dock="Right"
|
DockPanel.Dock="Right"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
<Copyright>Copyright © 2017-2024 (GPLv3)</Copyright>
|
<Copyright>Copyright © 2017-2024 (GPLv3)</Copyright>
|
||||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
|
<AssemblyName>v2rayN</AssemblyName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -284,6 +284,8 @@ namespace v2rayN.Views
|
|||||||
switch (e.Key)
|
switch (e.Key)
|
||||||
{
|
{
|
||||||
case Key.V:
|
case Key.V:
|
||||||
|
if (_backupAndRestoreView?.IsVisible == true) return;
|
||||||
|
|
||||||
var clipboardData = WindowsUtils.GetClipboardData();
|
var clipboardData = WindowsUtils.GetClipboardData();
|
||||||
ViewModel?.AddServerViaClipboardAsync(clipboardData);
|
ViewModel?.AddServerViaClipboardAsync(clipboardData);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user