Compare commits

...

4 commits

Author SHA1 Message Date
2dust
1c6323315b up 7.2.3
Some checks are pending
release macos / build (Release) (push) Waiting to run
release / build (Release) (push) Waiting to run
2024-11-29 11:43:53 +08:00
2dust
1ff4839be1 Bug fix
https://github.com/2dust/v2rayN/issues/6160
2024-11-29 11:31:22 +08:00
2dust
558e5bb340 Improve tun for linux 2024-11-29 10:31:57 +08:00
2dust
48a9d208e6 Label text optimization 2024-11-28 14:44:24 +08:00
10 changed files with 38 additions and 17 deletions

View file

@ -334,7 +334,7 @@ namespace ServiceLib.Handler
} }
try try
{ {
proc?.Kill(); proc?.Kill(true);
} }
catch (Exception) catch (Exception)
{ {
@ -375,7 +375,7 @@ namespace ServiceLib.Handler
private async Task KillProcessAsLinuxSudo() private async Task KillProcessAsLinuxSudo()
{ {
var cmdLine = $"kill -9 {_linuxSudoPid}"; var cmdLine = $"kill {_linuxSudoPid}";
var shFilePath = await CreateLinuxShellFile(cmdLine, "kill_as_sudo.sh"); var shFilePath = await CreateLinuxShellFile(cmdLine, "kill_as_sudo.sh");
Process proc = new() Process proc = new()
{ {
@ -392,11 +392,18 @@ namespace ServiceLib.Handler
if (_config.TunModeItem.LinuxSudoPwd.IsNotEmpty()) if (_config.TunModeItem.LinuxSudoPwd.IsNotEmpty())
{ {
var pwd = DesUtils.Decrypt(_config.TunModeItem.LinuxSudoPwd); try
await Task.Delay(10); {
await proc.StandardInput.WriteLineAsync(pwd); var pwd = DesUtils.Decrypt(_config.TunModeItem.LinuxSudoPwd);
await Task.Delay(10); await Task.Delay(10);
await proc.StandardInput.WriteLineAsync(pwd); await proc.StandardInput.WriteLineAsync(pwd);
await Task.Delay(10);
await proc.StandardInput.WriteLineAsync(pwd);
}
catch (Exception)
{
// ignored
}
} }
var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(10)); var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(10));
@ -411,7 +418,11 @@ namespace ServiceLib.Handler
File.Delete(shFilePath); File.Delete(shFilePath);
var sb = new StringBuilder(); var sb = new StringBuilder();
sb.AppendLine("#!/bin/sh"); sb.AppendLine("#!/bin/sh");
if (_config.TunModeItem.LinuxSudoPwd.IsNullOrEmpty()) if (AppHandler.Instance.IsAdministrator)
{
sb.AppendLine($"{cmdLine}");
}
else if (_config.TunModeItem.LinuxSudoPwd.IsNullOrEmpty())
{ {
sb.AppendLine($"pkexec {cmdLine}"); sb.AppendLine($"pkexec {cmdLine}");
} }

View file

@ -3140,7 +3140,7 @@ namespace ServiceLib.Resx {
} }
/// <summary> /// <summary>
/// 查找类似 Linux system sudo password 的本地化字符串。 /// 查找类似 System sudo password 的本地化字符串。
/// </summary> /// </summary>
public static string TbSettingsLinuxSudoPassword { public static string TbSettingsLinuxSudoPassword {
get { get {

View file

@ -1364,7 +1364,7 @@
<value>(Domain or IP or ProcName) and Port and Protocol and InboundTag =&gt; OutboundTag</value> <value>(Domain or IP or ProcName) and Port and Protocol and InboundTag =&gt; OutboundTag</value>
</data> </data>
<data name="TbSettingsLinuxSudoPassword" xml:space="preserve"> <data name="TbSettingsLinuxSudoPassword" xml:space="preserve">
<value>Linux system sudo password</value> <value>System sudo password</value>
</data> </data>
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve"> <data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
<value>The password is encrypted and stored only in local files.</value> <value>The password is encrypted and stored only in local files.</value>

View file

@ -1364,7 +1364,7 @@
<value>Remarks Memo</value> <value>Remarks Memo</value>
</data> </data>
<data name="TbSettingsLinuxSudoPassword" xml:space="preserve"> <data name="TbSettingsLinuxSudoPassword" xml:space="preserve">
<value>Linux system sudo password</value> <value>System sudo password</value>
</data> </data>
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve"> <data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
<value>The password is encrypted and stored only in local files.</value> <value>The password is encrypted and stored only in local files.</value>

View file

@ -1364,7 +1364,7 @@
<value>Remote (WebDAV)</value> <value>Remote (WebDAV)</value>
</data> </data>
<data name="TbSettingsLinuxSudoPassword" xml:space="preserve"> <data name="TbSettingsLinuxSudoPassword" xml:space="preserve">
<value>Linux system sudo password</value> <value>System sudo password</value>
</data> </data>
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve"> <data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
<value>The password is encrypted and stored only in local files.</value> <value>The password is encrypted and stored only in local files.</value>

View file

@ -1361,7 +1361,7 @@
<value>备注备忘</value> <value>备注备忘</value>
</data> </data>
<data name="TbSettingsLinuxSudoPassword" xml:space="preserve"> <data name="TbSettingsLinuxSudoPassword" xml:space="preserve">
<value>Linux系统的sudo密码</value> <value>系统的sudo密码</value>
</data> </data>
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve"> <data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
<value>密码已加密且只存储在本地文件中,无密码则每次都要输入</value> <value>密码已加密且只存储在本地文件中,无密码则每次都要输入</value>

View file

@ -1361,7 +1361,7 @@
<value>混淆密碼(obfs password)</value> <value>混淆密碼(obfs password)</value>
</data> </data>
<data name="TbSettingsLinuxSudoPassword" xml:space="preserve"> <data name="TbSettingsLinuxSudoPassword" xml:space="preserve">
<value>Linux系統的sudo密碼</value> <value>系統的sudo密碼</value>
</data> </data>
<data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve"> <data name="TbSettingsLinuxSudoPasswordTip" xml:space="preserve">
<value>密碼已加密且只儲存在本機檔案中,無密碼則每次都要輸入</value> <value>密碼已加密且只儲存在本機檔案中,無密碼則每次都要輸入</value>

View file

@ -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.2.2</Version> <Version>7.2.3</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View file

@ -283,7 +283,6 @@ namespace ServiceLib.ViewModels
try try
{ {
Logging.SaveLog("MyAppExit Begin"); Logging.SaveLog("MyAppExit Begin");
//if (blWindowsShutDown)
await SysProxyHandler.UpdateSysProxy(_config, true); await SysProxyHandler.UpdateSysProxy(_config, true);
await ConfigHandler.SaveConfig(_config); await ConfigHandler.SaveConfig(_config);
@ -297,7 +296,10 @@ namespace ServiceLib.ViewModels
catch { } catch { }
finally finally
{ {
_updateView?.Invoke(EViewAction.Shutdown, null); if (!blWindowsShutDown)
{
_updateView?.Invoke(EViewAction.Shutdown, null);
}
} }
} }

View file

@ -21,6 +21,7 @@ namespace v2rayN.Desktop.Views
private WindowNotificationManager? _manager; private WindowNotificationManager? _manager;
private CheckUpdateView? _checkUpdateView; private CheckUpdateView? _checkUpdateView;
private BackupAndRestoreView? _backupAndRestoreView; private BackupAndRestoreView? _backupAndRestoreView;
private bool _blCloseByUser = false;
public MainWindow() public MainWindow()
{ {
@ -279,6 +280,11 @@ namespace v2rayN.Desktop.Views
protected override async void OnClosing(WindowClosingEventArgs e) protected override async void OnClosing(WindowClosingEventArgs e)
{ {
if (_blCloseByUser)
{
return;
}
Logging.SaveLog("OnClosing -> " + e.CloseReason.ToString()); Logging.SaveLog("OnClosing -> " + e.CloseReason.ToString());
switch (e.CloseReason) switch (e.CloseReason)
@ -374,6 +380,8 @@ namespace v2rayN.Desktop.Views
{ {
return; return;
} }
_blCloseByUser = true;
StorageUI(); StorageUI();
await ViewModel?.MyAppExitAsync(false); await ViewModel?.MyAppExitAsync(false);