fix: gate node p2p behind explicit config

This commit is contained in:
lpf
2026-03-08 22:38:00 +08:00
parent 2aa7db9619
commit ad2e732f56
6 changed files with 97 additions and 5 deletions

View File

@@ -142,7 +142,17 @@ func NewAgentLoop(cfg *config.Config, msgBus *bus.MessageBus, provider providers
return nodes.Response{OK: false, Code: "unsupported_action", Node: "local", Action: req.Action, Error: "unsupported local simulated action"}
}
})
nodesRouter := &nodes.Router{P2P: &nodes.WebsocketP2PTransport{Manager: nodesManager}, Relay: &nodes.HTTPRelayTransport{Manager: nodesManager}}
var nodeP2P nodes.Transport
if cfg.Gateway.Nodes.P2P.Enabled {
switch strings.ToLower(strings.TrimSpace(cfg.Gateway.Nodes.P2P.Transport)) {
case "", "websocket_tunnel":
nodeP2P = &nodes.WebsocketP2PTransport{Manager: nodesManager}
case "webrtc":
// Keep the mode explicit but non-default until a direct data channel is production-ready.
nodeP2P = &nodes.WebsocketP2PTransport{Manager: nodesManager}
}
}
nodesRouter := &nodes.Router{P2P: nodeP2P, Relay: &nodes.HTTPRelayTransport{Manager: nodesManager}}
toolsRegistry.Register(tools.NewNodesTool(nodesManager, nodesRouter, filepath.Join(workspace, "memory", "nodes-dispatch-audit.jsonl")))
if cs != nil {