This commit is contained in:
DHR60 2026-03-01 08:10:20 +08:00
parent 584e538623
commit 0cd1e0bc87
2 changed files with 41 additions and 8 deletions

View file

@ -1251,7 +1251,7 @@ public static class ConfigHandler
return itemSocks; return itemSocks;
} }
public static CoreConfigContext? GetPreSocksCoreConfigContext(CoreConfigContext nodeContext) public static async Task<CoreConfigContextBuilderResult?> GetPreSocksCoreConfigContext(CoreConfigContext nodeContext)
{ {
var config = nodeContext.AppConfig; var config = nodeContext.AppConfig;
var node = nodeContext.Node; var node = nodeContext.Node;
@ -1260,7 +1260,15 @@ public static class ConfigHandler
var preSocksItem = GetPreSocksItem(config, node, coreType); var preSocksItem = GetPreSocksItem(config, node, coreType);
if (preSocksItem != null) 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) if ((!nodeContext.IsTunEnabled)
@ -1283,13 +1291,20 @@ public static class ConfigHandler
{ {
SsMethod = Global.None, 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, Context = preResult.Context with
TunProtectSsPort = tunProtectSsPort, {
ProxyRelaySsPort = proxyRelaySsPort, ProtectDomainList = protectDomainList2,
TunProtectSsPort = tunProtectSsPort,
ProxyRelaySsPort = proxyRelaySsPort,
}
}; };
return preContext; return preResult;
} }
/// <summary> /// <summary>

View file

@ -68,7 +68,25 @@ public class CoreManager
var contextMod = context; var contextMod = context;
var node = contextMod.Node; var node = contextMod.Node;
var fileName = Utils.GetBinConfigPath(Global.CoreConfigFileName); 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<string>([.. 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) if (preContext is not null)
{ {
contextMod = contextMod with contextMod = contextMod with