Skip to content

Commit

Permalink
select first as-set if PeeringDB field has a space in it
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Feb 25, 2021
1 parent 19ac4c9 commit 9d91b84
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,16 +526,26 @@ func main() {
log.Infof("[%s] has no IPv6 import limit configured. Setting to %d from PeeringDB", peerName, peeringDbData.MaxPfx6)
}

if peeringDbData.AsSet == "" {
log.Fatalf("[%s] has no as-set in PeeringDB", peerName)
// If the as-set has a space in it, split and pick the first element
if strings.Contains(peeringDbData.AsSet, " ") {
peeringDbData.AsSet = strings.Split(peeringDbData.AsSet, " ")[0]
log.Warnf("[%s] has a space in their PeeringDB as-set field. Selecting first element %s", peerName, peeringDbData.AsSet)
}

// Trim IRRDB prefix
if strings.Contains(peeringDbData.AsSet, "::") {
peerData.AsSet = strings.Split(peeringDbData.AsSet, "::")[1]
log.Warnf("[%s] has a IRRDB prefix in their PeeringDB as-set field. Using %s", peerName, peerData.AsSet)
} else {
peerData.AsSet = peeringDbData.AsSet
}

if peeringDbData.AsSet == "" {
log.Fatalf("[%s] has no as-set in PeeringDB", peerName)
} else {
log.Infof("[%s] as-set from PeeringDB: %s\n", peerName, peeringDbData.AsSet)
}

peerData.PrefixSet4 = getPrefixFilter(peerData.AsSet, 4, config.IrrDb)
peerData.PrefixSet6 = getPrefixFilter(peerData.AsSet, 6, config.IrrDb)

Expand Down Expand Up @@ -611,6 +621,7 @@ func main() {
}

// Render the template and write to disk
log.Infof("[%s] Writing config", peerName)
err = peerTemplate.ExecuteTemplate(peerSpecificFile, "peer.tmpl", &PeerTemplate{*peerData, config})
if err != nil {
log.Fatalf("Execute template: %v", err)
Expand Down

0 comments on commit 9d91b84

Please sign in to comment.