Skip to content

Commit 5ee55ad

Browse files
ribetmxddxdd
authored andcommitted
Support bird3 notation for BGP AS path
1 parent a778b49 commit 5ee55ad

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

frontend/bgpmap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var protocolNameRe = regexp.MustCompile(`\[(.*?) .*\]`)
1515
var routeSplitRe = regexp.MustCompile("(unicast|blackhole|unreachable|prohibited)")
1616

1717
var routeViaRe = regexp.MustCompile(`(?m)^\t(via .*?)$`)
18-
var routeASPathRe = regexp.MustCompile(`(?m)^\tBGP\.as_path: (.*?)$`)
18+
var routeASPathRe = regexp.MustCompile(`(?mi)^\tBGP(?:\.as)?_path: (.*?)$`)
1919

2020
func makeEdgeAttrs(preferred bool) RouteAttrs {
2121
result := RouteAttrs{

frontend/render.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func smartFormatter(s string) template.HTML {
8989
s = template.HTMLEscapeString(s)
9090
for _, line := range strings.Split(s, "\n") {
9191
var lineFormatted string
92-
if strings.HasPrefix(strings.TrimSpace(line), "BGP.as_path:") || strings.HasPrefix(strings.TrimSpace(line), "Neighbor AS:") || strings.HasPrefix(strings.TrimSpace(line), "Local AS:") {
92+
if strings.HasPrefix(strings.TrimSpace(line), "BGP.as_path:") || strings.HasPrefix(strings.TrimSpace(line), "bgp_path:") || strings.HasPrefix(strings.TrimSpace(line), "Neighbor AS:") || strings.HasPrefix(strings.TrimSpace(line), "Local AS:") {
9393
lineFormatted = regexp.MustCompile(`(\d+)`).ReplaceAllString(line, `<a href="/whois/AS${1}" class="whois">${1}</a>`)
9494
} else {
9595
lineFormatted = regexp.MustCompile(`([a-zA-Z0-9\-]*\.([a-zA-Z]{2,3}){1,2})(\s|$)`).ReplaceAllString(line, `<a href="/whois/${1}" class="whois">${1}</a>${3}`)

frontend/telegram_bot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func webHandlerTelegramBot(w http.ResponseWriter, r *http.Request) {
9797
} else if telegramIsCommand(request.Message.Text, "path") {
9898
commandResult = telegramBatchRequestFormat(servers, "bird", "show route for "+target+" all primary", func(result string) string {
9999
for _, s := range strings.Split(result, "\n") {
100-
if strings.Contains(s, "BGP.as_path: ") {
100+
if strings.Contains(s, "BGP.as_path: ") || strings.Contains(s, "bgp_path: ") {
101101
return strings.TrimSpace(strings.Split(s, ":")[1])
102102
}
103103
}

0 commit comments

Comments
 (0)