From ba5ad12e138140af46d6b4d9a2ba511292056f77 Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Fri, 15 Nov 2024 09:42:49 +0800
Subject: [PATCH 1/6] Linux password encryption storage
---
v2rayN/ServiceLib/Common/DesUtils.cs | 75 +++++++++++++++++++
v2rayN/ServiceLib/Handler/CoreHandler.cs | 10 ++-
v2rayN/ServiceLib/Models/ConfigItems.cs | 2 +-
v2rayN/ServiceLib/Resx/ResUI.Designer.cs | 2 +-
v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx | 2 +-
v2rayN/ServiceLib/Resx/ResUI.resx | 2 +-
v2rayN/ServiceLib/Resx/ResUI.ru.resx | 2 +-
v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx | 2 +-
v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx | 2 +-
.../ViewModels/OptionSettingViewModel.cs | 7 +-
.../ViewModels/StatusBarViewModel.cs | 2 +-
.../Views/OptionSettingWindow.axaml | 3 +-
12 files changed, 95 insertions(+), 16 deletions(-)
create mode 100644 v2rayN/ServiceLib/Common/DesUtils.cs
diff --git a/v2rayN/ServiceLib/Common/DesUtils.cs b/v2rayN/ServiceLib/Common/DesUtils.cs
new file mode 100644
index 00000000..132fff65
--- /dev/null
+++ b/v2rayN/ServiceLib/Common/DesUtils.cs
@@ -0,0 +1,75 @@
+using System.Security.Cryptography;
+using System.Text;
+
+namespace ServiceLib.Common
+{
+ public class DesUtils
+ {
+ ///
+ /// Encrypt
+ ///
+ ///
+ /// ///
+ ///
+ public static string Encrypt(string? text, string? key = null)
+ {
+ if (text.IsNullOrEmpty())
+ {
+ return string.Empty;
+ }
+ GetKeyIv(key ?? GetDefaultKey(), out var rgbKey, out var rgbIv);
+ var dsp = DES.Create();
+ using var memStream = new MemoryStream();
+ using var cryStream = new CryptoStream(memStream, dsp.CreateEncryptor(rgbKey, rgbIv), CryptoStreamMode.Write);
+ using var sWriter = new StreamWriter(cryStream);
+ sWriter.Write(text);
+ sWriter.Flush();
+ cryStream.FlushFinalBlock();
+ memStream.Flush();
+ return Convert.ToBase64String(memStream.GetBuffer(), 0, (int)memStream.Length);
+ }
+
+ ///
+ /// Decrypt
+ ///
+ ///
+ ///
+ ///
+ public static string Decrypt(string? encryptText, string? key = null)
+ {
+ if (encryptText.IsNullOrEmpty())
+ {
+ return string.Empty;
+ }
+ GetKeyIv(key ?? GetDefaultKey(), out var rgbKey, out var rgbIv);
+ var dsp = DES.Create();
+ var buffer = Convert.FromBase64String(encryptText);
+
+ using var memStream = new MemoryStream();
+ using var cryStream = new CryptoStream(memStream, dsp.CreateDecryptor(rgbKey, rgbIv), CryptoStreamMode.Write);
+ cryStream.Write(buffer, 0, buffer.Length);
+ cryStream.FlushFinalBlock();
+ return Encoding.UTF8.GetString(memStream.ToArray());
+ }
+
+ private static void GetKeyIv(string key, out byte[] rgbKey, out byte[] rgbIv)
+ {
+ if (key.IsNullOrEmpty())
+ {
+ throw new ArgumentNullException("The key cannot be null");
+ }
+ if (key.Length <= 8)
+ {
+ throw new ArgumentNullException("The key length cannot be less than 8 characters.");
+ }
+
+ rgbKey = Encoding.ASCII.GetBytes(key.Substring(0, 8));
+ rgbIv = Encoding.ASCII.GetBytes(key.Insert(0, "w").Substring(0, 8));
+ }
+
+ private static string GetDefaultKey()
+ {
+ return Utils.GetMd5(Utils.GetHomePath() + "DesUtils");
+ }
+ }
+}
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs
index cd8cdf51..6ebb80e8 100644
--- a/v2rayN/ServiceLib/Handler/CoreHandler.cs
+++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs
@@ -261,7 +261,7 @@ namespace ServiceLib.Handler
return _config.TunModeItem.EnableTun
&& eCoreType == ECoreType.sing_box
&& Utils.IsLinux()
- && _config.TunModeItem.LinuxSudoPassword.IsNotEmpty()
+ && _config.TunModeItem.LinuxSudoPwd.IsNotEmpty()
;
}
@@ -299,7 +299,8 @@ namespace ServiceLib.Handler
if (isNeedSudo)
{
proc.StartInfo.FileName = $"/bin/sudo";
- proc.StartInfo.Arguments = $"-S {fileName} {string.Format(coreInfo.Arguments, configPath)}";
+ proc.StartInfo.Arguments = $"-S {fileName} {string.Format(coreInfo.Arguments, Utils.GetConfigPath(configPath))}";
+ proc.StartInfo.WorkingDirectory = null;
proc.StartInfo.StandardInputEncoding = Encoding.UTF8;
proc.StartInfo.RedirectStandardInput = true;
}
@@ -328,10 +329,11 @@ namespace ServiceLib.Handler
if (isNeedSudo)
{
+ var pwd = DesUtils.Decrypt(_config.TunModeItem.LinuxSudoPwd);
await Task.Delay(10);
- await proc.StandardInput.WriteLineAsync(_config.TunModeItem.LinuxSudoPassword);
+ await proc.StandardInput.WriteLineAsync(pwd);
await Task.Delay(10);
- await proc.StandardInput.WriteLineAsync(_config.TunModeItem.LinuxSudoPassword);
+ await proc.StandardInput.WriteLineAsync(pwd);
}
if (displayLog)
diff --git a/v2rayN/ServiceLib/Models/ConfigItems.cs b/v2rayN/ServiceLib/Models/ConfigItems.cs
index 8ec47b88..06bcfbeb 100644
--- a/v2rayN/ServiceLib/Models/ConfigItems.cs
+++ b/v2rayN/ServiceLib/Models/ConfigItems.cs
@@ -161,7 +161,7 @@
public int Mtu { get; set; }
public bool EnableExInbound { get; set; }
public bool EnableIPv6Address { get; set; }
- public string? LinuxSudoPassword { get; set; }
+ public string? LinuxSudoPwd { get; set; }
}
[Serializable]
diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs
index 30568641..fa71ced0 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs
+++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs
@@ -3176,7 +3176,7 @@ namespace ServiceLib.Resx {
}
///
- /// 查找类似 The password will only be stored in the local file. 的本地化字符串。
+ /// 查找类似 The password is encrypted and stored only in local files. 的本地化字符串。
///
public static string TbSettingsLinuxSudoPasswordTip {
get {
diff --git a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx
index 991c9fe2..0bf2fecb 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx
@@ -1373,7 +1373,7 @@
Linux system sudo password
- The password will only be stored in the local file.
+ The password is encrypted and stored only in local files.
Please set the sudo password in Tun mode settings first
diff --git a/v2rayN/ServiceLib/Resx/ResUI.resx b/v2rayN/ServiceLib/Resx/ResUI.resx
index 9c69dc95..1d6b722b 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.resx
@@ -1373,7 +1373,7 @@
Linux system sudo password
- The password will only be stored in the local file.
+ The password is encrypted and stored only in local files.
Please set the sudo password in Tun mode settings first
diff --git a/v2rayN/ServiceLib/Resx/ResUI.ru.resx b/v2rayN/ServiceLib/Resx/ResUI.ru.resx
index 20395013..de7bce46 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.ru.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.ru.resx
@@ -1373,7 +1373,7 @@
Linux system sudo password
- The password will only be stored in the local file.
+ The password is encrypted and stored only in local files.
Please set the sudo password in Tun mode settings first
diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
index 18631825..55e14aed 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
@@ -1370,7 +1370,7 @@
Linux系统的sudo密码
- 密码只会存储在本地文件中,没有密码无法开启Tun
+ 密码已加密且只存储在本地文件中,无密码无法开启Tun
请先在Tun模式设置中设置sudo密码
diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
index c68e0da6..528ed027 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
@@ -1370,7 +1370,7 @@
Linux系統的sudo密碼
- 密碼只會儲存在本機檔案中,沒有密碼無法開啟Tun
+ 密碼已加密且只儲存在本機檔案中,無密碼無法開啟Tun
請先在Tun模式設定中設定sudo密碼
diff --git a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs
index 40aadaca..e1608906 100644
--- a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs
@@ -198,7 +198,7 @@ namespace ServiceLib.ViewModels
TunMtu = _config.TunModeItem.Mtu;
TunEnableExInbound = _config.TunModeItem.EnableExInbound;
TunEnableIPv6Address = _config.TunModeItem.EnableIPv6Address;
- TunLinuxSudoPassword = _config.TunModeItem.LinuxSudoPassword;
+ TunLinuxSudoPassword = _config.TunModeItem.LinuxSudoPwd;
#endregion Tun mode
@@ -342,7 +342,10 @@ namespace ServiceLib.ViewModels
_config.TunModeItem.Mtu = TunMtu;
_config.TunModeItem.EnableExInbound = TunEnableExInbound;
_config.TunModeItem.EnableIPv6Address = TunEnableIPv6Address;
- _config.TunModeItem.LinuxSudoPassword = TunLinuxSudoPassword;
+ if (TunLinuxSudoPassword != _config.TunModeItem.LinuxSudoPwd)
+ {
+ _config.TunModeItem.LinuxSudoPwd = DesUtils.Encrypt(TunLinuxSudoPassword);
+ }
//coreType
await SaveCoreType();
diff --git a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs
index 47c7312a..3298f636 100644
--- a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs
@@ -440,7 +440,7 @@ namespace ServiceLib.ViewModels
}
else if (Utils.IsLinux())
{
- return _config.TunModeItem.LinuxSudoPassword.IsNotEmpty();
+ return _config.TunModeItem.LinuxSudoPwd.IsNotEmpty();
}
return false;
}
diff --git a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml
index 6176dfe3..92919952 100644
--- a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml
+++ b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml
@@ -808,8 +808,7 @@
Grid.Column="1"
Width="200"
HorizontalAlignment="Left"
- Classes="Margin8"
- PasswordChar="*" />
+ Classes="Margin8" />
Date: Fri, 15 Nov 2024 11:59:22 +0800
Subject: [PATCH 2/6] Improve PAC
---
v2rayN/PacLib/PacHandler.cs | 45 ++++++++++---------
.../Handler/SysProxy/SysProxyHandler.cs | 39 +++++++---------
2 files changed, 40 insertions(+), 44 deletions(-)
diff --git a/v2rayN/PacLib/PacHandler.cs b/v2rayN/PacLib/PacHandler.cs
index 1481b94d..6801c69b 100644
--- a/v2rayN/PacLib/PacHandler.cs
+++ b/v2rayN/PacLib/PacHandler.cs
@@ -11,11 +11,11 @@ public class PacHandler
private static int _httpPort;
private static int _pacPort;
private static TcpListener? _tcpListener;
- private static string _pacText;
+ private static byte[] _writeContent;
private static bool _isRunning;
private static bool _needRestart = true;
- public static void Start(string configPath, int httpPort, int pacPort)
+ public static async Task Start(string configPath, int httpPort, int pacPort)
{
_needRestart = (configPath != _configPath || httpPort != _httpPort || pacPort != _pacPort || !_isRunning);
@@ -23,7 +23,7 @@ public class PacHandler
_httpPort = httpPort;
_pacPort = pacPort;
- InitText();
+ await InitText();
if (_needRestart)
{
@@ -32,15 +32,24 @@ public class PacHandler
}
}
- private static void InitText()
+ private static async Task InitText()
{
var path = Path.Combine(_configPath, "pac.txt");
if (!File.Exists(path))
{
- File.AppendAllText(path, Resources.ResourceManager.GetString("pac"));
+ await File.AppendAllTextAsync(path, Resources.ResourceManager.GetString("pac"));
}
- _pacText = File.ReadAllText(path).Replace("__PROXY__", $"PROXY 127.0.0.1:{_httpPort};DIRECT;");
+ var pacText = (await File.ReadAllTextAsync(path)).Replace("__PROXY__", $"PROXY 127.0.0.1:{_httpPort};DIRECT;");
+
+ var sb = new StringBuilder();
+ sb.AppendLine("HTTP/1.0 200 OK");
+ sb.AppendLine("Content-type:application/x-ns-proxy-autoconfig");
+ sb.AppendLine("Connection:close");
+ sb.AppendLine("Content-Length:" + Encoding.UTF8.GetByteCount(pacText));
+ sb.AppendLine();
+ sb.Append(pacText);
+ _writeContent = Encoding.UTF8.GetBytes(sb.ToString());
}
private static void RunListener()
@@ -60,21 +69,8 @@ public class PacHandler
continue;
}
- var client = _tcpListener.AcceptTcpClient();
- await Task.Run(() =>
- {
- var stream = client.GetStream();
- var sb = new StringBuilder();
- sb.AppendLine("HTTP/1.0 200 OK");
- sb.AppendLine("Content-type:application/x-ns-proxy-autoconfig");
- sb.AppendLine("Connection:close");
- sb.AppendLine("Content-Length:" + Encoding.UTF8.GetByteCount(_pacText));
- sb.AppendLine();
- sb.Append(_pacText);
- var content = Encoding.UTF8.GetBytes(sb.ToString());
- stream.Write(content, 0, content.Length);
- stream.Flush();
- });
+ var client = await _tcpListener.AcceptTcpClientAsync();
+ await Task.Run(() => { WriteContent(client); });
}
catch
{
@@ -84,6 +80,13 @@ public class PacHandler
}, TaskCreationOptions.LongRunning);
}
+ private static void WriteContent(TcpClient client)
+ {
+ var stream = client.GetStream();
+ stream.Write(_writeContent, 0, _writeContent.Length);
+ stream.Flush();
+ }
+
public static void Stop()
{
if (_tcpListener == null) return;
diff --git a/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs b/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs
index d6735e4b..de2ac9db 100644
--- a/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs
+++ b/v2rayN/ServiceLib/Handler/SysProxy/SysProxyHandler.cs
@@ -33,15 +33,10 @@ namespace ServiceLib.Handler.SysProxy
await ProxySettingLinux.SetProxy(Global.Loopback, port);
break;
- case ESysProxyType.ForcedChange:
- {
- if (Utils.IsOSX())
- {
- await ProxySettingOSX.SetProxy(Global.Loopback, port);
- }
+ case ESysProxyType.ForcedChange when Utils.IsOSX():
+ await ProxySettingOSX.SetProxy(Global.Loopback, port);
+ break;
- break;
- }
case ESysProxyType.ForcedClear when Utils.IsWindows():
ProxySettingWindows.UnsetProxy();
break;
@@ -50,23 +45,13 @@ namespace ServiceLib.Handler.SysProxy
await ProxySettingLinux.UnsetProxy();
break;
- case ESysProxyType.ForcedClear:
- {
- if (Utils.IsOSX())
- {
- await ProxySettingOSX.UnsetProxy();
- }
+ case ESysProxyType.ForcedClear when Utils.IsOSX():
+ await ProxySettingOSX.UnsetProxy();
+ break;
- break;
- }
case ESysProxyType.Pac when Utils.IsWindows():
- {
- var portPac = AppHandler.Instance.GetLocalPort(EInboundProtocol.pac);
- PacHandler.Start(Utils.GetConfigPath(), port, portPac);
- var strProxy = $"{Global.HttpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}";
- ProxySettingWindows.SetProxy(strProxy, "", 4);
- break;
- }
+ await SetWindowsProxyPac(port);
+ break;
}
if (type != ESysProxyType.Pac && Utils.IsWindows())
@@ -102,5 +87,13 @@ namespace ServiceLib.Handler.SysProxy
.Replace("{socks_port}", portSocks.ToString());
}
}
+
+ private static async Task SetWindowsProxyPac(int port)
+ {
+ var portPac = AppHandler.Instance.GetLocalPort(EInboundProtocol.pac);
+ await PacHandler.Start(Utils.GetConfigPath(), port, portPac);
+ var strProxy = $"{Global.HttpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}";
+ ProxySettingWindows.SetProxy(strProxy, "", 4);
+ }
}
}
\ No newline at end of file
From 5dbce16895cc6b1a78ae38625310083d35aef91f Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Fri, 15 Nov 2024 13:36:44 +0800
Subject: [PATCH 3/6] up 7.1.1
---
v2rayN/ServiceLib/ServiceLib.csproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/v2rayN/ServiceLib/ServiceLib.csproj b/v2rayN/ServiceLib/ServiceLib.csproj
index 83d73e70..ecd130e6 100644
--- a/v2rayN/ServiceLib/ServiceLib.csproj
+++ b/v2rayN/ServiceLib/ServiceLib.csproj
@@ -4,7 +4,7 @@
net8.0
enable
enable
- 7.1.0
+ 7.1.1
From 8f6d4431040e063fde22176cafba96e0dbf7ede6 Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Fri, 15 Nov 2024 19:50:37 +0800
Subject: [PATCH 4/6] Hide to tray when closing the window
https://github.com/2dust/v2rayN/issues/6076
---
v2rayN/ServiceLib/Models/ConfigItems.cs | 3 ++-
v2rayN/ServiceLib/Resx/ResUI.Designer.cs | 9 +++++++++
v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx | 3 +++
v2rayN/ServiceLib/Resx/ResUI.resx | 3 +++
v2rayN/ServiceLib/Resx/ResUI.ru.resx | 3 +++
v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx | 3 +++
v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx | 3 +++
v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs | 2 +-
.../ServiceLib/ViewModels/OptionSettingViewModel.cs | 3 +++
v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs | 4 ++--
.../v2rayN.Desktop/Views/OptionSettingWindow.axaml | 12 ++++++++++++
.../Views/OptionSettingWindow.axaml.cs | 1 +
12 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/v2rayN/ServiceLib/Models/ConfigItems.cs b/v2rayN/ServiceLib/Models/ConfigItems.cs
index 06bcfbeb..7de1794c 100644
--- a/v2rayN/ServiceLib/Models/ConfigItems.cs
+++ b/v2rayN/ServiceLib/Models/ConfigItems.cs
@@ -80,7 +80,7 @@
public bool IgnoreGeoUpdateCore { get; set; } = true;
public int AutoUpdateInterval { get; set; }
-
+
public bool EnableSecurityProtocolTls13 { get; set; }
public int TrayMenuServersLimit { get; set; } = 20;
@@ -116,6 +116,7 @@
public bool EnableDragDropSort { get; set; }
public bool DoubleClick2Activate { get; set; }
public bool AutoHideStartup { get; set; }
+ public bool Hide2TrayWhenClose { get; set; }
public List MainColumnItem { get; set; }
public bool ShowInTaskbar { get; set; }
}
diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs
index fa71ced0..a439d7c0 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs
+++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs
@@ -3103,6 +3103,15 @@ namespace ServiceLib.Resx {
}
}
+ ///
+ /// 查找类似 Hide to tray when closing the window 的本地化字符串。
+ ///
+ public static string TbSettingsHide2TrayWhenClose {
+ get {
+ return ResourceManager.GetString("TbSettingsHide2TrayWhenClose", resourceCulture);
+ }
+ }
+
///
/// 查找类似 HTTP Port 的本地化字符串。
///
diff --git a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx
index 0bf2fecb..937d107f 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx
@@ -1387,4 +1387,7 @@
XHTTP Extra raw JSON, format: { XHTTPObject }
+
+ Hide to tray when closing the window
+
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Resx/ResUI.resx b/v2rayN/ServiceLib/Resx/ResUI.resx
index 1d6b722b..af6a2c9e 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.resx
@@ -1387,4 +1387,7 @@
XHTTP Extra raw JSON, format: { XHTTPObject }
+
+ Hide to tray when closing the window
+
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Resx/ResUI.ru.resx b/v2rayN/ServiceLib/Resx/ResUI.ru.resx
index de7bce46..8758825c 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.ru.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.ru.resx
@@ -1387,4 +1387,7 @@
XHTTP Extra raw JSON, format: { XHTTPObject }
+
+ Hide to tray when closing the window
+
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
index 55e14aed..9fd66a6e 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
@@ -1384,4 +1384,7 @@
XHTTP Extra 原始 JSON,格式: { XHTTPObject }
+
+ 关闭窗口时隐藏至托盘
+
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
index 528ed027..c452a2ff 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
@@ -1384,4 +1384,7 @@
XHTTP Extra 原始 JSON,格式: { XHTTPObject }
+
+ 關閉視窗時隱藏至托盤
+
\ No newline at end of file
diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs
index a62c3f2a..5890d614 100644
--- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs
@@ -267,7 +267,7 @@ namespace ServiceLib.ViewModels
var filesList = (new DirectoryInfo(toPath)).GetFiles().Select(u => u.FullName).ToList();
foreach (var file in filesList)
{
- await Utils.SetLinuxChmod(Path.Combine(toPath, item.CoreType));
+ await Utils.SetLinuxChmod(Path.Combine(toPath, item.CoreType.ToLower()));
}
}
diff --git a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs
index e1608906..53fe1df6 100644
--- a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs
@@ -53,6 +53,7 @@ namespace ServiceLib.ViewModels
[Reactive] public bool EnableUpdateSubOnlyRemarksExist { get; set; }
[Reactive] public bool EnableSecurityProtocolTls13 { get; set; }
[Reactive] public bool AutoHideStartup { get; set; }
+ [Reactive] public bool Hide2TrayWhenClose { get; set; }
[Reactive] public bool EnableDragDropSort { get; set; }
[Reactive] public bool DoubleClick2Activate { get; set; }
[Reactive] public int AutoUpdateInterval { get; set; }
@@ -166,6 +167,7 @@ namespace ServiceLib.ViewModels
EnableUpdateSubOnlyRemarksExist = _config.UiItem.EnableUpdateSubOnlyRemarksExist;
EnableSecurityProtocolTls13 = _config.GuiItem.EnableSecurityProtocolTls13;
AutoHideStartup = _config.UiItem.AutoHideStartup;
+ Hide2TrayWhenClose = _config.UiItem.Hide2TrayWhenClose;
EnableDragDropSort = _config.UiItem.EnableDragDropSort;
DoubleClick2Activate = _config.UiItem.DoubleClick2Activate;
AutoUpdateInterval = _config.GuiItem.AutoUpdateInterval;
@@ -316,6 +318,7 @@ namespace ServiceLib.ViewModels
_config.UiItem.EnableUpdateSubOnlyRemarksExist = EnableUpdateSubOnlyRemarksExist;
_config.GuiItem.EnableSecurityProtocolTls13 = EnableSecurityProtocolTls13;
_config.UiItem.AutoHideStartup = AutoHideStartup;
+ _config.UiItem.Hide2TrayWhenClose = Hide2TrayWhenClose;
_config.GuiItem.AutoUpdateInterval = AutoUpdateInterval;
_config.UiItem.EnableDragDropSort = EnableDragDropSort;
_config.UiItem.DoubleClick2Activate = DoubleClick2Activate;
diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs
index 377e4689..a0ac88f8 100644
--- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs
+++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs
@@ -382,7 +382,7 @@ namespace v2rayN.Desktop.Views
#endregion Event
#region UI
-
+
public void ShowHideWindow(bool? blShow)
{
var bl = blShow ?? !_config.UiItem.ShowInTaskbar;
@@ -398,7 +398,7 @@ namespace v2rayN.Desktop.Views
}
else
{
- if (Utils.IsWindows())
+ if (_config.UiItem.Hide2TrayWhenClose)
{
this.Hide();
}
diff --git a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml
index 92919952..7f340867 100644
--- a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml
+++ b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml
@@ -489,6 +489,18 @@
HorizontalAlignment="Left"
Classes="Margin8" />
+
+
vm.EnableUpdateSubOnlyRemarksExist, v => v.togEnableUpdateSubOnlyRemarksExist.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableSecurityProtocolTls13, v => v.togEnableSecurityProtocolTls13.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AutoHideStartup, v => v.togAutoHideStartup.IsChecked).DisposeWith(disposables);
+ this.Bind(ViewModel, vm => vm.Hide2TrayWhenClose, v => v.togHide2TrayWhenClose.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.DoubleClick2Activate, v => v.togDoubleClick2Activate.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AutoUpdateInterval, v => v.txtautoUpdateInterval.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CurrentFontFamily, v => v.cmbcurrentFontFamily.SelectedValue).DisposeWith(disposables);
From e0086b4b79d5c1fad5b1fcf923c23bb6b8b7399b Mon Sep 17 00:00:00 2001
From: NagisaEfi <141222574+NagisaEfi@users.noreply.github.com>
Date: Sat, 16 Nov 2024 10:34:55 +0800
Subject: [PATCH 5/6] Update ResUI.zh-Hant.resx (#6080)
---
v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
index c452a2ff..0243c1f3 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
@@ -127,7 +127,7 @@
設定格式不正確
- 注意,自訂設定完全依賴您自己的設定,不能使用所有設定功能。如需使用系統代理請手動修改監聽埠。
+ 注意,自訂設定完全依賴您自己的設定,不能使用所有設定功能。如需使用系統代理請手動修改偵聽埠。
下載開始...
@@ -157,7 +157,7 @@
請填寫正確格式伺服器埠
- 請填寫本機監聽埠
+ 請填寫本機偵聽埠
請填寫密碼
@@ -722,7 +722,7 @@
例外. 對於下列字元開頭的位址不使用代理設定檔:使用分號(;)分隔
- 本機HTTP監聽埠
+ 本機HTTP偵聽埠
更新Core時忽略Geo檔案
@@ -755,7 +755,7 @@
開啟流量探測
- 本機SOCKS監聽埠
+ 本機SOCKS偵聽埠
開機啟動(可能會不成功)
@@ -998,7 +998,7 @@
複製字型TTF/TTC檔案到目錄guiFonts,重啟設定
- http端口= +1;Pac端口= +4;*ray API端口= +5;mihomo API端口= +6;
+ http連接埠= +1;Pac連接埠= +4;*ray API連接埠= +5;mihomo API連接埠= +6;
以管理員權限設定此項,在啟動後獲得管理員權限
@@ -1094,7 +1094,7 @@
請確保別名存在並且唯一
- 啟用額外監聽端口
+ 啟用額外偵聽連接埠
啟用IPv6
@@ -1154,7 +1154,7 @@
您目前運行的是獨立包,請手動下載 SelfContained.7z檔案解壓縮覆蓋!
- 自訂設定的Socks端口
+ 自訂設定的Socks連接埠
備份和還原
From 2ade705e516ed556a1e3717cb39cbd969c90e3ca Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Sat, 16 Nov 2024 20:15:05 +0800
Subject: [PATCH 6/6] Bug fix
---
v2rayN/ServiceLib/Handler/ConfigHandler.cs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs
index 9ebb928d..84e6b6b4 100644
--- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs
+++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs
@@ -959,7 +959,6 @@ namespace ServiceLib.Handler
&& o.Address == n.Address
&& o.Port == n.Port
&& o.Id == n.Id
- && o.AlterId == n.AlterId
&& o.Security == n.Security
&& o.Network == n.Network
&& o.HeaderType == n.HeaderType
@@ -968,6 +967,10 @@ namespace ServiceLib.Handler
&& (o.ConfigType == EConfigType.Trojan || o.StreamSecurity == n.StreamSecurity)
&& o.Flow == n.Flow
&& o.Sni == n.Sni
+ && o.Alpn == n.Alpn
+ && o.Fingerprint == n.Fingerprint
+ && o.PublicKey == n.PublicKey
+ && o.ShortId == n.ShortId
&& (!remarks || o.Remarks == n.Remarks);
}