chore: track version files, docs, web app split, scripts (missed commits from March work)

This commit is contained in:
2026-09-13 08:41:35 +08:00
parent 84c709bbcc
commit edf76db56b
33 changed files with 3082 additions and 504 deletions
+35 -1
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"log"
"net/netip"
"strings"
"github.com/openp2p-cn/inp2p/pkg/protocol"
)
@@ -35,17 +36,50 @@ func (s *Server) SetSDWANTenant(tenantID int64, cfg protocol.SDWANConfig, actorT
return errors.New("hub node must be online and relay-enabled")
}
}
cfg = s.rewriteTenantSDWAN(tenantID, cfg)
if err := s.sdwan.saveTenant(tenantID, cfg); err != nil {
return err
}
if actorType != "" && s.store != nil {
detail := fmt.Sprintf("mode=%s hub=%s nodes=%d subnetProxies=%d", cfg.Mode, cfg.HubNode, len(cfg.Nodes), len(cfg.SubnetProxies))
detail := fmt.Sprintf("mode=%s hub=%s nodes=%d subnetProxies=%d gateway=%s", cfg.Mode, cfg.HubNode, len(cfg.Nodes), len(cfg.SubnetProxies), cfg.GatewayCIDR)
_ = s.store.AddAuditLog(actorType, actorID, "sdwan_update", "tenant", fmt.Sprintf("%d", tenantID), detail, ip)
}
s.broadcastSDWANTenant(tenantID, s.sdwan.getTenant(tenantID))
return nil
}
func (s *Server) rewriteTenantSDWAN(tenantID int64, cfg protocol.SDWANConfig) protocol.SDWANConfig {
if s.store != nil {
if ten, err := s.store.GetTenantByID(tenantID); err == nil && ten != nil && ten.Subnet != "" {
cfg.GatewayCIDR = ten.Subnet
// keep routes aligned with subnet
found := false
for _, r := range cfg.Routes {
if strings.TrimSpace(r) == ten.Subnet {
found = true
break
}
}
if !found {
cfg.Routes = []string{ten.Subnet}
}
}
}
return cfg
}
func (s *Server) ReconcileTenantSDWAN(tenantID int64) {
cfg := s.sdwan.getTenant(tenantID)
cfg = s.rewriteTenantSDWAN(tenantID, cfg)
if err := s.sdwan.saveTenant(tenantID, cfg); err != nil {
log.Printf("[sdwan] reconcile tenant=%d failed: %v", tenantID, err)
return
}
s.broadcastSDWANTenant(tenantID, cfg)
}
func (s *Server) broadcastSDWAN(cfg protocol.SDWANConfig) {
if !cfg.Enabled || cfg.GatewayCIDR == "" {
return