applied gofmt

This commit is contained in:
Annika Hannig 2022-11-10 10:58:15 +01:00
parent ef3acbae17
commit 8ba9c09b80
8 changed files with 34 additions and 33 deletions

View File

@ -351,9 +351,8 @@ func (s *SearchFilters) GetGroupByKey(key string) *SearchFilterGroup {
// and its counters.
//
// Update filter struct to include route:
// - Extract ASN, source, bgp communites,
// - Find Filter in group, increment result count if required.
//
// - Extract ASN, source, bgp communites,
// - Find Filter in group, increment result count if required.
func (s *SearchFilters) UpdateFromLookupRoute(r *LookupRoute) {
// Add source
s.GetGroupByKey(SearchKeySources).AddFilter(&SearchFilter{
@ -425,16 +424,17 @@ func (s *SearchFilters) UpdateFromRoute(r *Route) {
// query parameters.
//
// For example a query string of:
// asns=2342,23123&communities=23:42&large_communities=23:42:42
//
// asns=2342,23123&communities=23:42&large_communities=23:42:42
//
// yields a filtering struct of
// Groups[
// Group{"sources", []},
// Group{"asns", [Filter{Value: 2342},
// Filter{Value: 23123}]},
// Group{"communities", ...
// }
//
// Groups[
// Group{"sources", []},
// Group{"asns", [Filter{Value: 2342},
// Filter{Value: 23123}]},
// Group{"communities", ...
// }
func FiltersFromQuery(query url.Values) (*SearchFilters, error) {
queryFilters := NewSearchFilters()
for key := range query {
@ -567,7 +567,6 @@ type NeighborFilter struct {
// and ASN.
//
// The latter is used to find related peers on all route servers.
//
func NeighborFilterFromQuery(q url.Values) *NeighborFilter {
asn := 0
name := q.Get("name")

View File

@ -2,7 +2,6 @@
// for the Alice Looking Glass.
//
// This configuration is read from a config file.
//
package config
import (
@ -275,7 +274,6 @@ func getRoutesColumnsDefaults() (map[string]string, []string, error) {
//
// In case the configuration is empty, fall back to
// the defaults as defined in getRoutesColumnsDefault()
//
func getRoutesColumns(config *ini.File) (map[string]string, []string, error) {
columns := make(map[string]string)
order := []string{}

View File

@ -6,11 +6,16 @@ import (
)
// ReMatchIPPrefix matches an IP prefix of the form:
// 2001:23:af...
//
// 2001:23:af...
//
// or
// 941.23.42.1 (required by NCIS)
//
// 941.23.42.1 (required by NCIS)
//
// or
// 303.735.88 (required by IKEA)
//
// 303.735.88 (required by IKEA)
var ReMatchIPPrefix = regexp.MustCompile(`([a-f0-9/]+[\.:]*)+`)
// MaybePrefix checks if something could be a prefix

View File

@ -119,9 +119,10 @@ func Duration(value interface{}, fallback time.Duration) time.Duration {
// According to https://github.com/openbgpd-portable/openbgpd-openbsd/blob/master/src/usr.sbin/bgpctl/bgpctl.c#L586-L591
// we have to parse %02lluw%01ud%02uh, %01ud%02uh%02um and %02u:%02u:%02u.
// This yields three formats:
// 01w3d01h
// 1d02h03m
// 01:02:03
//
// 01w3d01h
// 1d02h03m
// 01:02:03
func DurationTimeframe(value interface{}, fallback time.Duration) time.Duration {
var sec, min, hour, day uint
var week uint64

View File

@ -19,22 +19,22 @@ func makeQueryRequest(q string) *http.Request {
func makeQueryRoutes() api.Routes {
routes := api.Routes{
&api.Route{
ID: "route_01",
ID: "route_01",
NeighborID: "n01",
Network: "123.42.43.0/24",
Gateway: "23.42.42.1",
Network: "123.42.43.0/24",
Gateway: "23.42.42.1",
},
&api.Route{
ID: "route_02",
ID: "route_02",
NeighborID: "n01",
Network: "142.23.0.0/16",
Gateway: "42.42.42.1",
Network: "142.23.0.0/16",
Gateway: "42.42.42.1",
},
&api.Route{
ID: "route_03",
ID: "route_03",
NeighborID: "n01",
Network: "123.43.0.0/16",
Gateway: "23.42.43.1",
Network: "123.43.0.0/16",
Gateway: "23.42.43.1",
},
}

View File

@ -23,9 +23,8 @@ const (
// It is intendet to consume structured bgpctl output
// queried over HTTP using the:
//
// openbgpd-state-server
// https://github.com/alice-lg/openbgpd-state-server
//
// openbgpd-state-server
// https://github.com/alice-lg/openbgpd-state-server
type StateServerSource struct {
// cfg is the source configuration retrieved
// from the alice config file.

View File

@ -10,6 +10,7 @@ import (
)
// Include the schema through embedding
//
//go:embed schema.sql
var schema string

View File

@ -43,9 +43,7 @@ func importRoutes(
return s.sources.RefreshSuccess(src.ID)
}
//
// Route Store Tests
//
func makeTestRoutesStore() *RoutesStore {
neighborsStore := makeTestNeighborsStore()
be := memory.NewRoutesBackend()