quality / commitlint (push) Skipped
quality / changes (push) Successful in 8s
quality / docker-check (push) Skipped
quality / openapi (push) Successful in 26s
quality / web (push) Successful in 1m27s
quality / go (push) Successful in 1m18s
quality / bird2 (push) Successful in 16s
CD / quality (push) Successful in 3m43s
CD / publish (push) Successful in 3m11s
- Enhanced the speaker installation documentation to clarify the use of TCP port 179 and the logging commands for monitoring BIRD and evobgp-agent. - Updated the speaker form dialog to include additional information about MikroTik connections and logging commands. - Modified the BIRD configuration to include logging to stderr for better visibility during operations. - Adjusted the Docker Compose configuration to ensure proper network settings and sysctl configurations for BGP functionality.
72 lines
2.0 KiB
Go
72 lines
2.0 KiB
Go
package pipeline
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"evobgp/internal/birdfmt"
|
|
"evobgp/internal/store"
|
|
)
|
|
|
|
// BirdLocalsForSpeaker merges tenant settings with per-speaker meta_json overrides.
|
|
func BirdLocalsForSpeaker(st store.Backend, tenantID, speakerID string) birdLocals {
|
|
loc := birdLocalsFromStore(st, tenantID)
|
|
if st == nil || strings.TrimSpace(speakerID) == "" {
|
|
return loc
|
|
}
|
|
sp, err := st.GetSpeaker(tenantID, speakerID)
|
|
if err != nil || sp == nil {
|
|
return loc
|
|
}
|
|
meta := store.ParseSpeakerMeta(sp.MetaJSON)
|
|
src := strings.TrimSpace(meta.BirdBgpSourceIPv4)
|
|
if src == "" {
|
|
src = strings.TrimSpace(meta.NodeIPv4)
|
|
}
|
|
if src != "" {
|
|
loc.routerID = src
|
|
loc.localV4 = src
|
|
}
|
|
if s := strings.TrimSpace(meta.BirdBgpSourceIPv6); s != "" {
|
|
loc.localV6 = s
|
|
}
|
|
return loc
|
|
}
|
|
|
|
// OverlayFragmentsForSpeaker re-renders bird.conf and peers fragment with speaker-specific BIRD locals.
|
|
func OverlayFragmentsForSpeaker(st store.Backend, tenantID, speakerID, revisionID string, frags map[string]string) (map[string]string, error) {
|
|
if frags == nil {
|
|
frags = map[string]string{}
|
|
}
|
|
locals := BirdLocalsForSpeaker(st, tenantID, speakerID)
|
|
out := make(map[string]string, len(frags))
|
|
for k, v := range frags {
|
|
out[k] = v
|
|
}
|
|
moduleHint := "aggregate"
|
|
if main := frags["bird.conf"]; main != "" {
|
|
if idx := strings.Index(main, "trigger module "); idx >= 0 {
|
|
rest := main[idx+len("trigger module "):]
|
|
if end := strings.Index(rest, ")"); end > 0 {
|
|
moduleHint = strings.TrimSpace(rest[:end])
|
|
}
|
|
}
|
|
}
|
|
main, err := birdfmt.RenderMainBirdConf(birdfmt.MainBirdConfOptions{
|
|
RouterID: locals.routerID,
|
|
Includes: birdfmt.StandardIncludeFragments(),
|
|
Preamble: fmt.Sprintf("EvoBGP tenant aggregate config (trigger module %s) revision %s speaker %s", moduleHint, revisionID, speakerID),
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out["bird.conf"] = main
|
|
peersBody, err := renderPeersBirdFragment(st, tenantID, locals)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
pPeers := birdfmt.FragmentIncludePath(birdfmt.FragmentPeers)
|
|
out[pPeers] = peersBody
|
|
return out, nil
|
|
}
|