diff --git a/v2rayN/ServiceLib.Tests/Fmt/WireguardFmtTests.cs b/v2rayN/ServiceLib.Tests/Fmt/WireguardFmtTests.cs
index e9b5014d..717fa1bc 100644
--- a/v2rayN/ServiceLib.Tests/Fmt/WireguardFmtTests.cs
+++ b/v2rayN/ServiceLib.Tests/Fmt/WireguardFmtTests.cs
@@ -9,22 +9,23 @@ public class WireguardFmtTests
[Fact]
public void ResolveConfig_ShouldParsePeersAndIgnoreInlineComments()
{
- var config = """
- [Interface]
- PrivateKey = interface-private-key
- Address = 10.0.0.2/32, fd00::2/128 ; inline comment
- MTU = 1420
+ const string config =
+ """
+ [Interface]
+ PrivateKey = interface-private-key
+ Address = 10.0.0.2/32, fd00::2/128 ; inline comment
+ MTU = 1420
- [Peer]
- PublicKey = peer-public-key
- PresharedKey = peer-preshared-key
- Reserved = 1, 2, 3 # inline comment
- Endpoint = [2001:db8::1]:51820 # inline comment
+ [Peer]
+ PublicKey = peer-public-key
+ PresharedKey = peer-preshared-key
+ Reserved = 1, 2, 3 # inline comment
+ Endpoint = [2001:db8::1]:51820 # inline comment
- [Peer]
- PublicKey = peer-public-key-2
- Endpoint = example.com:12345
- """;
+ [Peer]
+ PublicKey = peer-public-key-2
+ Endpoint = example.com:12345
+ """;
var resolved = WireguardFmt.ResolveConfig(config);
@@ -43,4 +44,4 @@ public class WireguardFmtTests
second.Address.Should().Be("example.com");
second.Port.Should().Be(12345);
}
-}
\ No newline at end of file
+}
diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs
index 61511219..c4c7b8e9 100644
--- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs
+++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs
@@ -791,9 +791,22 @@ public static class ConfigHandler
profileItem.Address = profileItem.Address.TrimEx();
profileItem.Password = profileItem.Password.TrimEx();
var wgReserved = profileItem.GetProtocolExtra().WgReserved?.TrimEx();
- if (!wgReserved.IsNullOrEmpty())
+ if (!wgReserved.IsNullOrEmpty()
+ && !wgReserved.Contains(','))
{
- wgReserved = wgReserved.Replace(", ", ",");
+ // Base64 format, convert to standard format
+ try
+ {
+ var bytes = Convert.FromBase64String(wgReserved);
+ var reserved = new byte[3];
+ Array.Copy(bytes, reserved, Math.Min(bytes.Length, 3));
+
+ wgReserved = string.Join(", ", reserved);
+ }
+ catch
+ {
+ // If conversion fails, keep the original value
+ }
}
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with
{
@@ -1735,15 +1748,15 @@ public static class ConfigHandler
{
await RemoveServersViaSubid(config, subid, isSub);
}
- var lstSsServer = WireguardFmt.ResolveConfig(strData);
- if (lstSsServer?.Count > 0)
+ var lstServer = WireguardFmt.ResolveConfig(strData);
+ if (lstServer?.Count > 0)
{
var counter = 0;
- foreach (var ssItem in lstSsServer)
+ foreach (var item in lstServer)
{
- ssItem.Subid = subid;
- ssItem.IsSub = isSub;
- if (await AddWireguardServer(config, ssItem) == 0)
+ item.Subid = subid;
+ item.IsSub = isSub;
+ if (await AddWireguardServer(config, item) == 0)
{
counter++;
}
diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs
index 9e2340af..81efe4a5 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs
+++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs
@@ -3448,7 +3448,7 @@ namespace ServiceLib.Resx {
}
///
- /// 查找类似 Reserved (2,3,4) 的本地化字符串。
+ /// 查找类似 Reserved 的本地化字符串。
///
public static string TbReserved {
get {
diff --git a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx
index 26f1b4c4..e21d3fec 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx
@@ -1075,7 +1075,7 @@
کلید خصوصی
- Reserved (2,3,4)
+ Reserved
آدرس (IPv4, IPv6)
diff --git a/v2rayN/ServiceLib/Resx/ResUI.fr.resx b/v2rayN/ServiceLib/Resx/ResUI.fr.resx
index eec8f04b..898acc2a 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.fr.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.fr.resx
@@ -1072,7 +1072,7 @@
PrivateKey
- Reserved (2,3,4)
+ Reserved
Address (IPv4,IPv6)
diff --git a/v2rayN/ServiceLib/Resx/ResUI.hu.resx b/v2rayN/ServiceLib/Resx/ResUI.hu.resx
index 435dadf6..4eb6fc35 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.hu.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.hu.resx
@@ -1075,7 +1075,7 @@
Privát kulcs
- Fenntartott (2,3,4)
+ Fenntartott
Cím (IPv4, IPv6)
diff --git a/v2rayN/ServiceLib/Resx/ResUI.resx b/v2rayN/ServiceLib/Resx/ResUI.resx
index 242cc5c0..b5d832c6 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.resx
@@ -1075,7 +1075,7 @@
Private Key
- Reserved (2,3,4)
+ Reserved
Address (IPv4, IPv6)
diff --git a/v2rayN/ServiceLib/Resx/ResUI.ru.resx b/v2rayN/ServiceLib/Resx/ResUI.ru.resx
index 59111376..fa9bbce1 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.ru.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.ru.resx
@@ -1075,7 +1075,7 @@
Приватный ключ
- Зарезервировано (2, 3, 4)
+ Зарезервировано
Адрес (IPv4, IPv6)
diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
index 08fd1ce1..c6a6378b 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx
@@ -1072,7 +1072,7 @@
PrivateKey
- Reserved (2,3,4)
+ Reserved
Address (IPv4,IPv6)
diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
index 2ee14c77..821485e8 100644
--- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
+++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx
@@ -1072,7 +1072,7 @@
PrivateKey
- Reserved (2,3,4)
+ Reserved
Address (Ipv4,Ipv6)
diff --git a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxOutboundService.cs b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxOutboundService.cs
index 2634e388..8d36b353 100644
--- a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxOutboundService.cs
+++ b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxOutboundService.cs
@@ -309,7 +309,7 @@ public partial class CoreConfigSingboxService
{
var protocolExtra = _node.GetProtocolExtra();
- endpoint.address = Utils.String2List(protocolExtra.WgInterfaceAddress);
+ endpoint.address = Utils.String2List(protocolExtra.WgInterfaceAddress)?.Select(s => s.Trim()).ToList() ?? ["172.16.0.2/32"];
endpoint.type = Global.ProtocolTypes[_node.ConfigType];
switch (_node.ConfigType)
@@ -320,7 +320,7 @@ public partial class CoreConfigSingboxService
{
public_key = protocolExtra.WgPublicKey ?? string.Empty,
pre_shared_key = protocolExtra.WgPresharedKey,
- reserved = Utils.String2List(protocolExtra.WgReserved)?.Select(int.Parse).ToList(),
+ reserved = Utils.String2List(protocolExtra.WgReserved)?.Select(s => s.Trim()).Select(int.Parse).ToList(),
address = _node.Address,
port = _node.Port,
allowed_ips = ["0.0.0.0/0", "::/0"],
diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs
index f840492f..f3836960 100644
--- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs
+++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayOutboundService.cs
@@ -263,9 +263,9 @@ public partial class CoreConfigV2rayService
};
var setting = new Outboundsettings4Ray
{
- address = Utils.String2List(protocolExtra.WgInterfaceAddress),
+ address = Utils.String2List(protocolExtra.WgInterfaceAddress)?.Select(s => s.Trim()).ToList() ?? ["172.16.0.2/32"],
secretKey = _node.Password,
- reserved = Utils.String2List(protocolExtra.WgReserved)?.Select(int.Parse).ToList(),
+ reserved = Utils.String2List(protocolExtra.WgReserved)?.Select(s => s.Trim()).Select(int.Parse).ToList(),
mtu = protocolExtra.WgMtu > 0 ? protocolExtra.WgMtu : Global.TunMtus.First(),
peers = [peer]
};
diff --git a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml
index 2aaa83ad..dbf031b1 100644
--- a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml
+++ b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml
@@ -563,7 +563,7 @@
Grid.Column="1"
Width="400"
Margin="{StaticResource Margin4}"
- Watermark="2,3,4" />
+ Watermark="0, 0, 0" />