feat: add xhttp transport, network monitoring and kernel auto-switch

This commit is contained in:
xboard
2026-04-18 01:39:49 +08:00
parent 65d97f3da1
commit 71c53e1071
5 changed files with 175 additions and 1 deletions
+15
View File
@@ -11,6 +11,7 @@ import (
"github.com/cedar2025/xboard-node/internal/config"
"github.com/cedar2025/xboard-node/internal/controlplane"
"github.com/cedar2025/xboard-node/internal/model"
"github.com/cedar2025/xboard-node/internal/monitor"
"github.com/cedar2025/xboard-node/internal/nlog"
"github.com/cedar2025/xboard-node/internal/panel"
@@ -134,6 +135,19 @@ func (o *Orchestrator) startNode(ctx context.Context, mn panel.MachineNode) {
perNodeClient := o.client.ForNode(mn.ID)
// Pre-fetch node config to detect transport-based kernel requirements.
// If the transport (e.g. xhttp) is incompatible with the configured kernel
// (e.g. singbox), auto-switch to the required kernel for this node.
if cfgSnapshot, err := perNodeClient.GetConfig(); err == nil && cfgSnapshot != nil {
if resolved := model.ResolveKernelForTransport(cfgSnapshot.Network, nodeCfg.Kernel.Type); resolved != nodeCfg.Kernel.Type {
nlog.Core().Info(fmt.Sprintf("machine: auto-switching kernel for node %d (%s→%s, transport=%s)",
mn.ID, nodeCfg.Kernel.Type, resolved, cfgSnapshot.Network))
nodeCfg.Kernel.Type = resolved
}
}
// Reset cached ETag so the subsequent GetConfig in Initial() gets a full response.
perNodeClient.ResetConfigETag()
var push controlplane.PushClient
if o.ws != nil {
push = &machineNodePush{
@@ -247,6 +261,7 @@ func (o *Orchestrator) reportMachineStatus() {
[2]uint64{s.MemTotal, s.MemUsed},
[2]uint64{s.SwapTotal, s.SwapUsed},
[2]uint64{s.DiskTotal, s.DiskUsed},
s.NetInSpeed, s.NetOutSpeed,
); err != nil {
nlog.Core().Warn("machine status report failed", "error", err)
}