experimental query
This commit is contained in:
parent
b21c47c8de
commit
1b600447a8
@ -26,14 +26,17 @@ func (s *Server) apiLookupPrefixGlobal(
|
||||
|
||||
// Get prefix to query
|
||||
q, err := validateQueryString(req, "q")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
/*
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
*/
|
||||
|
||||
// Check what we want to query
|
||||
// Prefix -> fetch prefix
|
||||
// _ -> fetch neighbors and routes
|
||||
lookupPrefix := decoders.MaybePrefix(q)
|
||||
lookupPrefix = true
|
||||
|
||||
// Measure response time
|
||||
t0 := time.Now()
|
||||
@ -44,13 +47,20 @@ func (s *Server) apiLookupPrefixGlobal(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
filtersApplied.GetGroupByKey(api.SearchKeyCommunities).AddFilter(&api.SearchFilter{
|
||||
Name: "65104:150",
|
||||
Value: api.Community{65104, 150},
|
||||
})
|
||||
|
||||
// Perform query
|
||||
var routes api.LookupRoutes
|
||||
if lookupPrefix {
|
||||
q, err = validatePrefixQuery(q)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
/*
|
||||
q, err = validatePrefixQuery(q)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
*/
|
||||
routes, err = s.routesStore.LookupPrefix(ctx, q, filtersApplied)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -99,10 +99,11 @@ func (r *RoutesBackend) FindByPrefix(
|
||||
// We make our compare case insensitive
|
||||
prefix = strings.ToLower(prefix)
|
||||
result := api.LookupRoutes{}
|
||||
hasPrefix := prefix != ""
|
||||
r.routes.Range(func(k, rs interface{}) bool {
|
||||
for _, route := range rs.(api.LookupRoutes) {
|
||||
// Naiive string filtering:
|
||||
if !strings.HasPrefix(strings.ToLower(route.Network), prefix) {
|
||||
if hasPrefix && !strings.HasPrefix(strings.ToLower(route.Network), prefix) {
|
||||
continue
|
||||
}
|
||||
if !filters.MatchRoute(route) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user