sdwan: add hub node selection and auto fallback to mesh

This commit is contained in:
2026-03-05 22:03:26 +08:00
parent 5fe5c76375
commit e96a2e5dd9
5 changed files with 60 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
package server
import (
"errors"
"log"
"net/netip"
@@ -24,6 +25,15 @@ func (s *Server) SetSDWAN(cfg protocol.SDWANConfig) error {
}
func (s *Server) SetSDWANTenant(tenantID int64, cfg protocol.SDWANConfig) error {
if cfg.Mode == "hub" {
if cfg.HubNode == "" {
return errors.New("hub mode requires hubNode")
}
hub := s.GetNode(cfg.HubNode)
if hub == nil || !hub.IsOnline() || hub.TenantID != tenantID || !hub.RelayEnabled {
return errors.New("hub node must be online and relay-enabled")
}
}
if err := s.sdwan.saveTenant(tenantID, cfg); err != nil {
return err
}