Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6391667c15 | ||
|
|
7f26445327 | ||
|
|
291d4bd8e5 | ||
|
|
f2f3a7eb5f | ||
|
|
e7609619d4 | ||
|
|
84bf9ecfaf | ||
|
|
a2917b3ce8 | ||
|
|
d094370209 | ||
|
|
1a6fbf782d |
2
.github/workflows/build-linux.yml
vendored
2
.github/workflows/build-linux.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
||||
fetch-depth: '0'
|
||||
|
||||
- name: Setup
|
||||
uses: actions/setup-dotnet@v4.3.1
|
||||
uses: actions/setup-dotnet@v5.0.0
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
|
||||
2
.github/workflows/build-osx.yml
vendored
2
.github/workflows/build-osx.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
||||
fetch-depth: '0'
|
||||
|
||||
- name: Setup
|
||||
uses: actions/setup-dotnet@v4.3.1
|
||||
uses: actions/setup-dotnet@v5.0.0
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
|
||||
2
.github/workflows/build-windows-desktop.yml
vendored
2
.github/workflows/build-windows-desktop.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
||||
fetch-depth: '0'
|
||||
|
||||
- name: Setup
|
||||
uses: actions/setup-dotnet@v4.3.1
|
||||
uses: actions/setup-dotnet@v5.0.0
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
|
||||
2
.github/workflows/build-windows.yml
vendored
2
.github/workflows/build-windows.yml
vendored
@@ -30,7 +30,7 @@ jobs:
|
||||
uses: actions/checkout@v5.0.0
|
||||
|
||||
- name: Setup
|
||||
uses: actions/setup-dotnet@v4.3.1
|
||||
uses: actions/setup-dotnet@v5.0.0
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
|
||||
@@ -52,7 +52,17 @@ sudo chmod 0755 "${PackagePath}/DEBIAN/postinst"
|
||||
sudo chmod 0755 "${PackagePath}/opt/v2rayN/v2rayN"
|
||||
sudo chmod 0755 "${PackagePath}/opt/v2rayN/AmazTool"
|
||||
|
||||
# desktop && PATH
|
||||
# Patch
|
||||
# set owner to root:root
|
||||
sudo chown -R root:root "${PackagePath}"
|
||||
# set all directories to 755 (readable & traversable by all users)
|
||||
sudo find "${PackagePath}/opt/v2rayN" -type d -exec chmod 755 {} +
|
||||
# set all regular files to 644 (readable by all users)
|
||||
sudo find "${PackagePath}/opt/v2rayN" -type f -exec chmod 644 {} +
|
||||
# ensure main binaries are 755 (executable by all users)
|
||||
sudo chmod 755 "${PackagePath}/opt/v2rayN/v2rayN" 2>/dev/null || true
|
||||
sudo chmod 755 "${PackagePath}/opt/v2rayN/AmazTool" 2>/dev/null || true
|
||||
|
||||
# build deb package
|
||||
sudo dpkg-deb -Zxz --build $PackagePath
|
||||
sudo mv "${PackagePath}.deb" "v2rayN-${Arch}.deb"
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>7.14.5</Version>
|
||||
<Version>7.14.7</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
<CentralPackageVersionOverrideEnabled>false</CentralPackageVersionOverrideEnabled>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.3.4" />
|
||||
<PackageVersion Include="Avalonia.Desktop" Version="11.3.4" />
|
||||
<PackageVersion Include="Avalonia.Diagnostics" Version="11.3.4" />
|
||||
<PackageVersion Include="Avalonia.ReactiveUI" Version="11.3.4" />
|
||||
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.3.5" />
|
||||
<PackageVersion Include="Avalonia.Desktop" Version="11.3.5" />
|
||||
<PackageVersion Include="Avalonia.Diagnostics" Version="11.3.5" />
|
||||
<PackageVersion Include="Avalonia.ReactiveUI" Version="11.3.5" />
|
||||
<PackageVersion Include="CliWrap" Version="3.9.0" />
|
||||
<PackageVersion Include="Downloader" Version="4.0.3" />
|
||||
<PackageVersion Include="H.NotifyIcon.Wpf" Version="2.3.0" />
|
||||
@@ -20,7 +20,7 @@
|
||||
<PackageVersion Include="ReactiveUI.WPF" Version="20.4.1" />
|
||||
<PackageVersion Include="Semi.Avalonia" Version="11.2.1.9" />
|
||||
<PackageVersion Include="Semi.Avalonia.DataGrid" Version="11.2.1.9" />
|
||||
<PackageVersion Include="Splat.NLog" Version="15.5.3" />
|
||||
<PackageVersion Include="Splat.NLog" Version="16.2.1" />
|
||||
<PackageVersion Include="sqlite-net-pcl" Version="1.9.172" />
|
||||
<PackageVersion Include="TaskScheduler" Version="2.12.2" />
|
||||
<PackageVersion Include="WebDav.Client" Version="2.9.0" />
|
||||
|
||||
@@ -15,7 +15,6 @@ public enum EViewAction
|
||||
ShowHideWindow,
|
||||
ScanScreenTask,
|
||||
ScanImageTask,
|
||||
Shutdown,
|
||||
BrowseServer,
|
||||
ImportRulesFromFile,
|
||||
InitSettingFont,
|
||||
|
||||
@@ -13,6 +13,8 @@ public static class AppEvents
|
||||
|
||||
public static readonly Subject<Unit> AppExitRequested = new();
|
||||
|
||||
public static readonly Subject<bool> ShutdownRequested = new();
|
||||
|
||||
public static readonly Subject<Unit> AdjustMainLvColWidthRequested = new();
|
||||
|
||||
public static readonly Subject<ServerSpeedItem> DispatcherStatisticsRequested = new();
|
||||
|
||||
@@ -2321,10 +2321,22 @@ public static class ConfigHandler
|
||||
config.ConstItem.SrsSourceUrl = Global.SingboxRulesetSources[1];
|
||||
config.ConstItem.RouteRulesTemplateSourceUrl = Global.RoutingRulesSources[1];
|
||||
|
||||
await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[1] + "v2ray.json"));
|
||||
await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[1] + "sing_box.json"));
|
||||
var xrayDnsRussia = await GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[1] + "v2ray.json");
|
||||
var singboxDnsRussia = await GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[1] + "sing_box.json");
|
||||
var simpleDnsRussia = await GetExternalSimpleDNSItem(Global.DNSTemplateSources[1] + "simple_dns.json");
|
||||
|
||||
config.SimpleDNSItem = await GetExternalSimpleDNSItem(Global.DNSTemplateSources[1] + "simple_dns.json") ?? InitBuiltinSimpleDNS();
|
||||
if (simpleDnsRussia == null)
|
||||
{
|
||||
xrayDnsRussia.Enabled = true;
|
||||
singboxDnsRussia.Enabled = true;
|
||||
config.SimpleDNSItem = InitBuiltinSimpleDNS();
|
||||
}
|
||||
else
|
||||
{
|
||||
config.SimpleDNSItem = simpleDnsRussia;
|
||||
}
|
||||
await SaveDNSItems(config, xrayDnsRussia);
|
||||
await SaveDNSItems(config, singboxDnsRussia);
|
||||
break;
|
||||
|
||||
case EPresetType.Iran:
|
||||
@@ -2332,10 +2344,22 @@ public static class ConfigHandler
|
||||
config.ConstItem.SrsSourceUrl = Global.SingboxRulesetSources[2];
|
||||
config.ConstItem.RouteRulesTemplateSourceUrl = Global.RoutingRulesSources[2];
|
||||
|
||||
await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[2] + "v2ray.json"));
|
||||
await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[2] + "sing_box.json"));
|
||||
var xrayDnsIran = await GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[2] + "v2ray.json");
|
||||
var singboxDnsIran = await GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[2] + "sing_box.json");
|
||||
var simpleDnsIran = await GetExternalSimpleDNSItem(Global.DNSTemplateSources[2] + "simple_dns.json");
|
||||
|
||||
config.SimpleDNSItem = await GetExternalSimpleDNSItem(Global.DNSTemplateSources[2] + "simple_dns.json") ?? InitBuiltinSimpleDNS();
|
||||
if (simpleDnsIran == null)
|
||||
{
|
||||
xrayDnsIran.Enabled = true;
|
||||
singboxDnsIran.Enabled = true;
|
||||
config.SimpleDNSItem = InitBuiltinSimpleDNS();
|
||||
}
|
||||
else
|
||||
{
|
||||
config.SimpleDNSItem = simpleDnsIran;
|
||||
}
|
||||
await SaveDNSItems(config, xrayDnsIran);
|
||||
await SaveDNSItems(config, singboxDnsIran);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using System.Reactive;
|
||||
|
||||
namespace ServiceLib.Manager;
|
||||
|
||||
public sealed class AppManager
|
||||
@@ -34,7 +36,7 @@ public sealed class AppManager
|
||||
|
||||
#endregion Property
|
||||
|
||||
#region Init
|
||||
#region App
|
||||
|
||||
public bool InitApp()
|
||||
{
|
||||
@@ -87,7 +89,40 @@ public sealed class AppManager
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion Init
|
||||
public async Task AppExitAsync(bool needShutdown)
|
||||
{
|
||||
try
|
||||
{
|
||||
Logging.SaveLog("AppExitAsync Begin");
|
||||
|
||||
await SysProxyHandler.UpdateSysProxy(_config, true);
|
||||
AppEvents.AppExitRequested.OnNext(Unit.Default);
|
||||
await Task.Delay(50); //Wait for AppExitRequested to be processed
|
||||
|
||||
await ConfigHandler.SaveConfig(_config);
|
||||
await ProfileExManager.Instance.SaveTo();
|
||||
await StatisticsManager.Instance.SaveTo();
|
||||
await CoreManager.Instance.CoreStop();
|
||||
StatisticsManager.Instance.Close();
|
||||
|
||||
Logging.SaveLog("AppExitAsync End");
|
||||
}
|
||||
catch { }
|
||||
finally
|
||||
{
|
||||
if (needShutdown)
|
||||
{
|
||||
Shutdown(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Shutdown(bool byUser)
|
||||
{
|
||||
AppEvents.ShutdownRequested.OnNext(byUser);
|
||||
}
|
||||
|
||||
#endregion App
|
||||
|
||||
#region Config
|
||||
|
||||
|
||||
@@ -136,8 +136,7 @@ public class BackupAndRestoreViewModel : MyReactiveObject
|
||||
var result = await CreateZipFileFromDirectory(fileBackup);
|
||||
if (result)
|
||||
{
|
||||
var service = Locator.Current.GetService<MainWindowViewModel>();
|
||||
await service?.MyAppExitAsync(true);
|
||||
await AppManager.Instance.AppExitAsync(false);
|
||||
await SQLiteHelper.Instance.DisposeDbConnectionAsync();
|
||||
|
||||
var toPath = Utils.GetConfigPath();
|
||||
@@ -154,7 +153,7 @@ public class BackupAndRestoreViewModel : MyReactiveObject
|
||||
_ = ProcUtils.ProcessStart(upgradeFileName, Global.RebootAs, Utils.StartupPath());
|
||||
}
|
||||
}
|
||||
service?.Shutdown(true);
|
||||
AppManager.Instance.Shutdown(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -236,12 +236,19 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!Utils.UpgradeAppExists(out _))
|
||||
if (!Utils.UpgradeAppExists(out var upgradeFileName))
|
||||
{
|
||||
await UpdateView(_v2rayN, ResUI.UpgradeAppNotExistTip);
|
||||
NoticeManager.Instance.SendMessageAndEnqueue(ResUI.UpgradeAppNotExistTip);
|
||||
Logging.SaveLog("UpgradeApp does not exist");
|
||||
return;
|
||||
}
|
||||
Locator.Current.GetService<MainWindowViewModel>()?.UpgradeApp(fileName);
|
||||
|
||||
var id = ProcUtils.ProcessStart(upgradeFileName, fileName, Utils.StartupPath());
|
||||
if (id > 0)
|
||||
{
|
||||
await AppManager.Instance.AppExitAsync(true);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -282,59 +282,11 @@ public class MainWindowViewModel : MyReactiveObject
|
||||
AppEvents.DispatcherStatisticsRequested.OnNext(update);
|
||||
}
|
||||
|
||||
public async Task MyAppExitAsync(bool blWindowsShutDown)
|
||||
{
|
||||
try
|
||||
{
|
||||
Logging.SaveLog("MyAppExitAsync Begin");
|
||||
|
||||
await SysProxyHandler.UpdateSysProxy(_config, true);
|
||||
AppEvents.AppExitRequested.OnNext(Unit.Default);
|
||||
|
||||
await ConfigHandler.SaveConfig(_config);
|
||||
await ProfileExManager.Instance.SaveTo();
|
||||
await StatisticsManager.Instance.SaveTo();
|
||||
await CoreManager.Instance.CoreStop();
|
||||
StatisticsManager.Instance.Close();
|
||||
|
||||
Logging.SaveLog("MyAppExitAsync End");
|
||||
}
|
||||
catch { }
|
||||
finally
|
||||
{
|
||||
if (!blWindowsShutDown)
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.Shutdown, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpgradeApp(string arg)
|
||||
{
|
||||
if (!Utils.UpgradeAppExists(out var upgradeFileName))
|
||||
{
|
||||
NoticeManager.Instance.SendMessageAndEnqueue(ResUI.UpgradeAppNotExistTip);
|
||||
Logging.SaveLog("UpgradeApp does not exist");
|
||||
return;
|
||||
}
|
||||
|
||||
var id = ProcUtils.ProcessStart(upgradeFileName, arg, Utils.StartupPath());
|
||||
if (id > 0)
|
||||
{
|
||||
await MyAppExitAsync(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowHideWindow(bool? blShow)
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.ShowHideWindow, blShow);
|
||||
}
|
||||
|
||||
public void Shutdown(bool byUser)
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.Shutdown, byUser);
|
||||
}
|
||||
|
||||
#endregion Actions
|
||||
|
||||
#region Servers && Groups
|
||||
@@ -517,7 +469,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||
public async Task RebootAsAdmin()
|
||||
{
|
||||
ProcUtils.RebootAsAdmin();
|
||||
await MyAppExitAsync(false);
|
||||
await AppManager.Instance.AppExitAsync(true);
|
||||
}
|
||||
|
||||
private async Task ClearServerStatistics()
|
||||
|
||||
@@ -74,11 +74,7 @@ public partial class App : Application
|
||||
|
||||
private async void MenuExit_Click(object? sender, EventArgs e)
|
||||
{
|
||||
var service = Locator.Current.GetService<MainWindowViewModel>();
|
||||
if (service != null)
|
||||
{
|
||||
await service.MyAppExitAsync(true);
|
||||
}
|
||||
service?.Shutdown(true);
|
||||
await AppManager.Instance.AppExitAsync(false);
|
||||
AppManager.Instance.Shutdown(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +148,12 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(_ => StorageUI())
|
||||
.DisposeWith(disposables);
|
||||
|
||||
AppEvents.ShutdownRequested
|
||||
.AsObservable()
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(content => Shutdown(content))
|
||||
.DisposeWith(disposables);
|
||||
});
|
||||
|
||||
if (Utils.IsWindows())
|
||||
@@ -222,19 +228,6 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||
DispatcherPriority.Default);
|
||||
break;
|
||||
|
||||
case EViewAction.Shutdown:
|
||||
if (obj != null && _blCloseByUser == false)
|
||||
{
|
||||
_blCloseByUser = (bool)obj;
|
||||
}
|
||||
StorageUI();
|
||||
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
HotkeyManager.Instance.Dispose();
|
||||
desktop.Shutdown();
|
||||
}
|
||||
break;
|
||||
|
||||
case EViewAction.ScanScreenTask:
|
||||
await ScanScreenTaskAsync();
|
||||
break;
|
||||
@@ -289,10 +282,7 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||
break;
|
||||
|
||||
case WindowCloseReason.ApplicationShutdown or WindowCloseReason.OSShutdown:
|
||||
if (ViewModel != null)
|
||||
{
|
||||
await ViewModel.MyAppExitAsync(true);
|
||||
}
|
||||
await AppManager.Instance.AppExitAsync(false);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -387,9 +377,21 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||
|
||||
_blCloseByUser = true;
|
||||
StorageUI();
|
||||
if (ViewModel != null)
|
||||
|
||||
await AppManager.Instance.AppExitAsync(true);
|
||||
}
|
||||
|
||||
private void Shutdown(bool obj)
|
||||
{
|
||||
await ViewModel.MyAppExitAsync(false);
|
||||
if (obj is bool b && _blCloseByUser == false)
|
||||
{
|
||||
_blCloseByUser = b;
|
||||
}
|
||||
StorageUI();
|
||||
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
HotkeyManager.Instance.Dispose();
|
||||
desktop.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -145,6 +145,12 @@ public partial class MainWindow
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(_ => StorageUI())
|
||||
.DisposeWith(disposables);
|
||||
|
||||
AppEvents.ShutdownRequested
|
||||
.AsObservable()
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(content => Shutdown(content))
|
||||
.DisposeWith(disposables);
|
||||
});
|
||||
|
||||
this.Title = $"{Utils.GetVersion()} - {(Utils.IsAdministrator() ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}";
|
||||
@@ -212,13 +218,6 @@ public partial class MainWindow
|
||||
}), DispatcherPriority.Normal);
|
||||
break;
|
||||
|
||||
case EViewAction.Shutdown:
|
||||
Application.Current?.Dispatcher.Invoke((() =>
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
}), DispatcherPriority.Normal);
|
||||
break;
|
||||
|
||||
case EViewAction.ScanScreenTask:
|
||||
await ScanScreenTaskAsync();
|
||||
break;
|
||||
@@ -266,7 +265,12 @@ public partial class MainWindow
|
||||
{
|
||||
Logging.SaveLog("Current_SessionEnding");
|
||||
StorageUI();
|
||||
await ViewModel?.MyAppExitAsync(true);
|
||||
await AppManager.Instance.AppExitAsync(false);
|
||||
}
|
||||
|
||||
private void Shutdown(bool obj)
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
||||
private void MainWindow_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
|
||||
@@ -97,9 +97,7 @@ public partial class StatusBarView
|
||||
private async void menuExit_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
tbNotify.Dispose();
|
||||
var service = Locator.Current.GetService<MainWindowViewModel>();
|
||||
if (service != null)
|
||||
await service.MyAppExitAsync(false);
|
||||
await AppManager.Instance.AppExitAsync(true);
|
||||
}
|
||||
|
||||
private void txtRunningInfoDisplay_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user