* Fix

* Build all contexts

* Notify validator result

* Fix
This commit is contained in:
DHR60
2026-03-01 05:47:48 +00:00
committed by GitHub
parent a3ff31088e
commit 6b4ae5a386
6 changed files with 144 additions and 93 deletions
+7 -15
View File
@@ -57,27 +57,19 @@ public class CoreManager
}
}
public async Task LoadCore(CoreConfigContext? context)
/// <param name="mainContext">Resolved main context (with pre-socks ports already merged if applicable).</param>
/// <param name="preContext">Optional pre-socks context passed to <see cref="CoreStartPreService"/>.</param>
public async Task LoadCore(CoreConfigContext? mainContext, CoreConfigContext? preContext)
{
if (context == null)
if (mainContext == null)
{
await UpdateFunc(false, ResUI.CheckServerSettings);
return;
}
var contextMod = context;
var node = contextMod.Node;
var node = mainContext.Node;
var fileName = Utils.GetBinConfigPath(Global.CoreConfigFileName);
var preContext = ConfigHandler.GetPreSocksCoreConfigContext(contextMod);
if (preContext is not null)
{
contextMod = contextMod with
{
TunProtectSsPort = preContext.TunProtectSsPort,
ProxyRelaySsPort = preContext.ProxyRelaySsPort,
};
}
var result = await CoreConfigHandler.GenerateClientConfig(contextMod, fileName);
var result = await CoreConfigHandler.GenerateClientConfig(mainContext, fileName);
if (result.Success != true)
{
await UpdateFunc(true, result.Msg);
@@ -96,7 +88,7 @@ public class CoreManager
await WindowsUtils.RemoveTunDevice();
}
await CoreStart(contextMod);
await CoreStart(mainContext);
await CoreStartPreService(preContext);
if (_processService != null)
{
@@ -38,4 +38,25 @@ public class NoticeManager
Enqueue(msg);
SendMessage(msg);
}
/// <summary>
/// Sends each error and warning in <paramref name="validatorResult"/> to the message panel
/// and enqueues a summary snack notification (capped at 10 messages).
/// Returns <c>true</c> when there were any messages so the caller can decide on early-return
/// based on <see cref="NodeValidatorResult.Success"/>.
/// </summary>
public bool NotifyValidatorResult(NodeValidatorResult validatorResult)
{
var msgs = new List<string>([.. validatorResult.Errors, .. validatorResult.Warnings]);
if (msgs.Count == 0)
{
return false;
}
foreach (var msg in msgs)
{
SendMessage(msg);
}
Enqueue(Utils.List2String(msgs.Take(10).ToList(), true));
return true;
}
}