diff --git a/bird/bird.go b/bird/bird.go index 84a2daf..3cc3b4b 100644 --- a/bird/bird.go +++ b/bird/bird.go @@ -119,6 +119,10 @@ func RoutesProtoCount(protocol string) (Parsed, bool) { parseRoutesCount) } +func RoutesFiltered(protocol string) (Parsed, bool) { + return RunAndParse("route protocol '"+protocol+"' filtered", parseRoutes) +} + func RoutesExport(protocol string) (Parsed, bool) { return RunAndParse("route export '"+protocol+"' all", parseRoutes) diff --git a/birdwatcher.go b/birdwatcher.go index 6d6ec4f..e9b9d2e 100644 --- a/birdwatcher.go +++ b/birdwatcher.go @@ -55,6 +55,9 @@ func makeRouter(config endpoints.ServerConfig) *httprouter.Router { if isModuleEnabled("routes_count_table", whitelist) { r.GET("/routes/count/table/:table", endpoints.Endpoint(endpoints.TableCount)) } + if isModuleEnabled("routes_filtered", whitelist) { + r.GET("routes/filtered/:protocol", endpoints.Endpoint(endpoints.RoutesFiltered)) + } if isModuleEnabled("route_net", whitelist) { r.GET("/route/net/:net", endpoints.Endpoint(endpoints.RouteNet)) r.GET("/route/net/:net/table/:table", endpoints.Endpoint(endpoints.RouteNetTable)) diff --git a/endpoints/routes.go b/endpoints/routes.go index f13becd..a398ce9 100644 --- a/endpoints/routes.go +++ b/endpoints/routes.go @@ -15,6 +15,14 @@ func ProtoRoutes(ps httprouter.Params) (bird.Parsed, bool) { return bird.RoutesProto(protocol) } +func RoutesFiltered(ps httprouter.Params) (bird.Parsed, bool) { + protocol, err := ValidateProtocolParam(ps.ByName("protocol")) + if err != nil { + return bird.Parsed{"error": fmt.Sprintf("%s", err)}, false + } + return bird.RoutesFiltered(protocol) +} + func TableRoutes(ps httprouter.Params) (bird.Parsed, bool) { return bird.RoutesTable(ps.ByName("table")) }