Add PR test (#9244)

* Add pr test

* Fix
This commit is contained in:
DHR60
2026-05-06 07:35:53 +00:00
committed by GitHub
parent 1a44af33d0
commit f073b14fcc
6 changed files with 35 additions and 4 deletions
+29
View File
@@ -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
@@ -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);
@@ -19,4 +19,5 @@ public record CoreConfigContext
public HashSet<string> ProtectDomainList { get; init; } = [];
public bool IsWindows { get; init; }
public bool IsMacOS { get; init; }
}
@@ -62,7 +62,7 @@ public partial class CoreConfigSingboxService
}
var tunInbound = JsonUtils.Deserialize<Inbound4Sbox>(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;
@@ -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);
}
@@ -54,7 +54,7 @@ public partial class CoreConfigV2rayService
_config.TunModeItem.Mtu = Global.TunMtus.First();
}
var tunInbound = JsonUtils.Deserialize<Inbounds4Ray>(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)
{