From f073b14fcc34cef19c9fb8cd18dba8d3c741fea0 Mon Sep 17 00:00:00 2001 From: DHR60 Date: Wed, 6 May 2026 07:35:53 +0000 Subject: [PATCH] Add PR test (#9244) * Add pr test * Fix --- .github/workflows/test.yml | 29 +++++++++++++++++++ .../Builder/CoreConfigContextBuilder.cs | 1 + v2rayN/ServiceLib/Models/CoreConfigContext.cs | 1 + .../Singbox/SingboxInboundService.cs | 2 +- .../CoreConfig/V2ray/V2rayDnsService.cs | 4 +-- .../CoreConfig/V2ray/V2rayInboundService.cs | 2 +- 6 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..9364283f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,29 @@ +name: Code Test + +on: + pull_request: + branches: + - master + paths: + - 'v2rayN/ServiceLib/Services/CoreConfig/**' + - 'v2rayN/ServiceLib/Handler/Fmt/**' + - '.github/workflows/test.yml' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6.0.2 + with: + submodules: 'recursive' + fetch-depth: '0' + + - name: Setup .NET + uses: actions/setup-dotnet@v5.2.0 + with: + dotnet-version: '8.0.x' + + - name: Test Code + working-directory: ./v2rayN + run: dotnet test ./ServiceLib.Tests diff --git a/v2rayN/ServiceLib/Handler/Builder/CoreConfigContextBuilder.cs b/v2rayN/ServiceLib/Handler/Builder/CoreConfigContextBuilder.cs index 1b681661..eb1af21b 100644 --- a/v2rayN/ServiceLib/Handler/Builder/CoreConfigContextBuilder.cs +++ b/v2rayN/ServiceLib/Handler/Builder/CoreConfigContextBuilder.cs @@ -48,6 +48,7 @@ public class CoreConfigContextBuilder RawDnsItem = await AppManager.Instance.GetDNSItem(coreType), RoutingItem = await ConfigHandler.GetDefaultRouting(config), IsWindows = Utils.IsWindows(), + IsMacOS = Utils.IsMacOS(), }; var validatorResult = NodeValidatorResult.Empty(); var (actNode, nodeValidatorResult) = await ResolveNodeAsync(context, node); diff --git a/v2rayN/ServiceLib/Models/CoreConfigContext.cs b/v2rayN/ServiceLib/Models/CoreConfigContext.cs index e85d5385..4b64efca 100644 --- a/v2rayN/ServiceLib/Models/CoreConfigContext.cs +++ b/v2rayN/ServiceLib/Models/CoreConfigContext.cs @@ -19,4 +19,5 @@ public record CoreConfigContext public HashSet ProtectDomainList { get; init; } = []; public bool IsWindows { get; init; } + public bool IsMacOS { get; init; } } diff --git a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxInboundService.cs b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxInboundService.cs index 13c4e40b..b1e24a74 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxInboundService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/Singbox/SingboxInboundService.cs @@ -62,7 +62,7 @@ public partial class CoreConfigSingboxService } var tunInbound = JsonUtils.Deserialize(EmbedUtils.GetEmbedText(Global.TunSingboxInboundFileName)) ?? new Inbound4Sbox { }; - tunInbound.interface_name = Utils.IsMacOS() ? $"utun{new Random().Next(99)}" : "singbox_tun"; + tunInbound.interface_name = context.IsMacOS ? $"utun{new Random().Next(99)}" : "singbox_tun"; tunInbound.mtu = _config.TunModeItem.Mtu; tunInbound.auto_route = _config.TunModeItem.AutoRoute; tunInbound.strict_route = _config.TunModeItem.StrictRoute; diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayDnsService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayDnsService.cs index 1777d16a..abb3e134 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayDnsService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayDnsService.cs @@ -200,9 +200,9 @@ public partial class CoreConfigV2rayService if (normalizedDomain.StartsWith(Global.GeoSitePrefix) || normalizedDomain.StartsWith("ext:")) { var isExpectedDomain = !regionName.IsNullOrEmpty() - || normalizedDomain.EndsWith($"-{regionName}") + && (normalizedDomain.EndsWith($"-{regionName}") || normalizedDomain.EndsWith($"@{regionName}") - || normalizedDomain == Global.GeoSitePrefix + regionName; + || normalizedDomain == Global.GeoSitePrefix + regionName); var targetList = isExpectedDomain ? expectedDomainList : directGeositeList; targetList.Add(normalizedDomain); } diff --git a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayInboundService.cs b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayInboundService.cs index 9cb02e01..91c8c133 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayInboundService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/V2ray/V2rayInboundService.cs @@ -54,7 +54,7 @@ public partial class CoreConfigV2rayService _config.TunModeItem.Mtu = Global.TunMtus.First(); } var tunInbound = JsonUtils.Deserialize(EmbedUtils.GetEmbedText(Global.V2raySampleTunInbound)) ?? new Inbounds4Ray { }; - tunInbound.settings.name = Utils.IsMacOS() ? $"utun{new Random().Next(99)}" : "xray_tun"; + tunInbound.settings.name = context.IsMacOS ? $"utun{new Random().Next(99)}" : "xray_tun"; tunInbound.settings.MTU = _config.TunModeItem.Mtu; if (_config.TunModeItem.EnableIPv6Address == false) {