From c18e199804b4c3a7092d4f012fb21a96e17020cc Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 8 May 2026 19:31:22 +0800 Subject: [PATCH] Update CoreConfigSingboxServiceTests.cs --- .../Singbox/CoreConfigSingboxServiceTests.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/v2rayN/ServiceLib.Tests/CoreConfig/Singbox/CoreConfigSingboxServiceTests.cs b/v2rayN/ServiceLib.Tests/CoreConfig/Singbox/CoreConfigSingboxServiceTests.cs index fb0b3c51..158ba239 100644 --- a/v2rayN/ServiceLib.Tests/CoreConfig/Singbox/CoreConfigSingboxServiceTests.cs +++ b/v2rayN/ServiceLib.Tests/CoreConfig/Singbox/CoreConfigSingboxServiceTests.cs @@ -1,6 +1,7 @@ using AwesomeAssertions; using ServiceLib.Common; using ServiceLib.Enums; +using ServiceLib.Manager; using ServiceLib.Models; using ServiceLib.Services.CoreConfig; using Xunit; @@ -28,6 +29,31 @@ public class CoreConfigSingboxServiceTests singboxConfig.inbounds.Should().Contain(i => i.type == nameof(EInboundProtocol.mixed)); } + [Fact] + public void GenerateClientConfigContent_TunWithLoopbackPreSocks_ShouldKeepMixedInbound() + { + var config = CoreConfigTestFactory.CreateConfig(ECoreType.sing_box); + CoreConfigTestFactory.BindAppManagerConfig(config); + var node = CoreConfigTestFactory.CreateSocksNode(ECoreType.sing_box); + node.Address = Global.Loopback; + node.Port = 1080; + var context = CoreConfigTestFactory.CreateContext(config, node, ECoreType.sing_box) with + { + IsTunEnabled = true, + }; + + var result = new CoreConfigSingboxService(context).GenerateClientConfigContent(); + + result.Success.Should().BeTrue($"ret msg: {result.Msg}"); + var cfg = JsonUtils.Deserialize(result.Data!.ToString())!; + + cfg.inbounds.Should().Contain(i => + i.type == nameof(EInboundProtocol.mixed) + && i.listen == Global.Loopback + && i.listen_port == AppManager.Instance.GetLocalPort(EInboundProtocol.socks)); + cfg.inbounds.Should().Contain(i => i.type == "tun"); + } + [Fact] public void GenerateClientConfigContent_BindInterface_ShouldUseDialBindInterface() {