From 0cd1e0bc8771e8efa272e3dfd35cfa4bab617e9d Mon Sep 17 00:00:00 2001 From: DHR60 Date: Sun, 1 Mar 2026 08:10:20 +0800 Subject: [PATCH] Fix --- v2rayN/ServiceLib/Handler/ConfigHandler.cs | 29 ++++++++++++++++------ v2rayN/ServiceLib/Manager/CoreManager.cs | 20 ++++++++++++++- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index b0bde1df..faa35650 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -1251,7 +1251,7 @@ public static class ConfigHandler return itemSocks; } - public static CoreConfigContext? GetPreSocksCoreConfigContext(CoreConfigContext nodeContext) + public static async Task GetPreSocksCoreConfigContext(CoreConfigContext nodeContext) { var config = nodeContext.AppConfig; var node = nodeContext.Node; @@ -1260,7 +1260,15 @@ public static class ConfigHandler var preSocksItem = GetPreSocksItem(config, node, coreType); if (preSocksItem != null) { - return nodeContext with { Node = preSocksItem, }; + var preSocksResult = await CoreConfigContextBuilder.Build(nodeContext.AppConfig, preSocksItem); + // share protect domain + var protectDomainList = nodeContext.ProtectDomainList ?? []; + protectDomainList.UnionWith(preSocksResult.Context.ProtectDomainList ?? []); + preSocksResult = preSocksResult with + { + Context = preSocksResult.Context with { ProtectDomainList = protectDomainList, } + }; + return preSocksResult; } if ((!nodeContext.IsTunEnabled) @@ -1283,13 +1291,20 @@ public static class ConfigHandler { SsMethod = Global.None, }); - var preContext = nodeContext with + var preResult = await CoreConfigContextBuilder.Build(nodeContext.AppConfig, preItem); + // share protect domain + var protectDomainList2 = nodeContext.ProtectDomainList ?? []; + protectDomainList2.UnionWith(preResult.Context.ProtectDomainList ?? []); + preResult = preResult with { - Node = preItem, - TunProtectSsPort = tunProtectSsPort, - ProxyRelaySsPort = proxyRelaySsPort, + Context = preResult.Context with + { + ProtectDomainList = protectDomainList2, + TunProtectSsPort = tunProtectSsPort, + ProxyRelaySsPort = proxyRelaySsPort, + } }; - return preContext; + return preResult; } /// diff --git a/v2rayN/ServiceLib/Manager/CoreManager.cs b/v2rayN/ServiceLib/Manager/CoreManager.cs index cd30450f..83355597 100644 --- a/v2rayN/ServiceLib/Manager/CoreManager.cs +++ b/v2rayN/ServiceLib/Manager/CoreManager.cs @@ -68,7 +68,25 @@ public class CoreManager var contextMod = context; var node = contextMod.Node; var fileName = Utils.GetBinConfigPath(Global.CoreConfigFileName); - var preContext = ConfigHandler.GetPreSocksCoreConfigContext(contextMod); + var preResult = await ConfigHandler.GetPreSocksCoreConfigContext(contextMod); + if (preResult is not null) + { + var validatorResult = preResult.ValidatorResult; + var msgs = new List([.. validatorResult.Errors, .. validatorResult.Warnings]); + if (msgs.Count > 0) + { + foreach (var msg in msgs) + { + await UpdateFunc(false, msg); + } + await UpdateFunc(true, Utils.List2String(msgs.Take(10).ToList(), true)); + if (!validatorResult.Success) + { + return; + } + } + } + var preContext = preResult?.Context; if (preContext is not null) { contextMod = contextMod with