Show AS descriptions in AS path on prefix detail page
- Display AS descriptions alongside AS numbers in format: Description (ASN) - Truncate descriptions longer than 20 characters with ellipsis - Increase container max width to 1600px for better display - Enable word wrapping for AS path cells to handle long paths - Update mobile responsive styles for AS path display
This commit is contained in:
@@ -15,10 +15,16 @@ import (
|
||||
|
||||
"git.eeqj.de/sneak/routewatch/internal/database"
|
||||
"git.eeqj.de/sneak/routewatch/internal/templates"
|
||||
"git.eeqj.de/sneak/routewatch/pkg/asinfo"
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
const (
|
||||
// maxASDescriptionLength is the maximum length for AS descriptions in the UI
|
||||
maxASDescriptionLength = 20
|
||||
)
|
||||
|
||||
// handleRoot returns a handler that redirects to /status
|
||||
func (s *Server) handleRoot() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -645,12 +651,45 @@ func (s *Server) handlePrefixDetail() http.HandlerFunc {
|
||||
origins = append(origins, origin)
|
||||
}
|
||||
|
||||
// Create enhanced routes with AS path descriptions
|
||||
type ASPathEntry struct {
|
||||
Number int
|
||||
Description string
|
||||
}
|
||||
type EnhancedRoute struct {
|
||||
database.LiveRoute
|
||||
ASPathWithDesc []ASPathEntry
|
||||
}
|
||||
|
||||
enhancedRoutes := make([]EnhancedRoute, len(routes))
|
||||
for i, route := range routes {
|
||||
enhancedRoute := EnhancedRoute{
|
||||
LiveRoute: route,
|
||||
ASPathWithDesc: make([]ASPathEntry, len(route.ASPath)),
|
||||
}
|
||||
|
||||
// Look up description for each AS in the path
|
||||
for j, asn := range route.ASPath {
|
||||
desc := asinfo.GetDescription(asn)
|
||||
// Truncate description if longer than maxASDescriptionLength characters
|
||||
if len(desc) > maxASDescriptionLength {
|
||||
desc = desc[:maxASDescriptionLength] + "..."
|
||||
}
|
||||
enhancedRoute.ASPathWithDesc[j] = ASPathEntry{
|
||||
Number: asn,
|
||||
Description: desc,
|
||||
}
|
||||
}
|
||||
|
||||
enhancedRoutes[i] = enhancedRoute
|
||||
}
|
||||
|
||||
// Prepare template data
|
||||
data := struct {
|
||||
Prefix string
|
||||
MaskLength int
|
||||
IPVersion int
|
||||
Routes []database.LiveRoute
|
||||
Routes []EnhancedRoute
|
||||
Origins []*ASNInfo
|
||||
PeerCount int
|
||||
OriginCount int
|
||||
@@ -658,7 +697,7 @@ func (s *Server) handlePrefixDetail() http.HandlerFunc {
|
||||
Prefix: prefix,
|
||||
MaskLength: maskLength,
|
||||
IPVersion: ipVersion,
|
||||
Routes: routes,
|
||||
Routes: enhancedRoutes,
|
||||
Origins: origins,
|
||||
PeerCount: len(routes),
|
||||
OriginCount: len(originMap),
|
||||
|
||||
Reference in New Issue
Block a user