refactor: update worker processes in EvoBGP to accept dependencies for shared store and job registry. Enhance scheduler, ingest, render, and deploy components to utilize a unified context and improve logging for drift detection. Update architecture documentation to reflect changes in process interactions and worker functionalities.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"net/netip"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ParseCIDRLines extracts unique IPv4/IPv6 CIDRs from plain text (one per line, # comments, empty lines skipped).
|
||||
func ParseCIDRLines(body string) []netip.Prefix {
|
||||
seen := make(map[string]struct{})
|
||||
var out []netip.Prefix
|
||||
sc := bufio.NewScanner(strings.NewReader(body))
|
||||
for sc.Scan() {
|
||||
line := strings.TrimSpace(sc.Text())
|
||||
if line == "" || strings.HasPrefix(line, "#") {
|
||||
continue
|
||||
}
|
||||
pfx := parseOneCIDR(line)
|
||||
if !pfx.IsValid() {
|
||||
continue
|
||||
}
|
||||
m := pfx.Masked()
|
||||
s := m.String()
|
||||
if _, ok := seen[s]; ok {
|
||||
continue
|
||||
}
|
||||
seen[s] = struct{}{}
|
||||
out = append(out, m)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func parseOneCIDR(s string) netip.Prefix {
|
||||
if p, err := netip.ParsePrefix(s); err == nil {
|
||||
return p
|
||||
}
|
||||
if addr, err := netip.ParseAddr(s); err == nil {
|
||||
if addr.Is4() {
|
||||
p, _ := addr.Prefix(32)
|
||||
return p
|
||||
}
|
||||
p, _ := addr.Prefix(128)
|
||||
return p
|
||||
}
|
||||
return netip.Prefix{}
|
||||
}
|
||||
Reference in New Issue
Block a user