1
0
Fork 0
mirror of https://github.com/alice-lg/birdwatcher.git synced 2025-03-09 00:00:05 +01:00

added parser configuration for (for now exclusively) filtering fields from route parses

This commit is contained in:
hellerve 2017-02-22 18:09:45 +01:00
parent 3e8140a414
commit 8e2e8d2a97
5 changed files with 27 additions and 1 deletions

View file

@ -15,6 +15,10 @@ type BirdConfig struct {
BirdCmd string `toml:"birdc"`
}
type ParserConfig struct {
FilterFields []string `toml:"filter_fields"`
}
type RateLimitConfig struct {
Reqs int
Max int `toml:"requests_per_minute"`

View file

@ -6,8 +6,19 @@ import (
"strings"
)
var ParserConf ParserConfig
type Parsed map[string]interface{}
func dirtyContains(l []string, e string) bool {
for _, c := range l {
if c == e {
return true
}
}
return false
}
func emptyLine(line string) bool {
return len(strings.TrimSpace(line)) == 0
}
@ -117,6 +128,13 @@ func mainRouteDetail(groups []string, route Parsed) Parsed {
route["learnt_from"] = groups[6]
route["primary"] = groups[7] == "*"
route["metric"] = parseInt(groups[8])
for k, _ := range route {
if !dirtyContains(ParserConf.FilterFields, k) {
route[k] = nil
}
}
return route
}

View file

@ -125,6 +125,7 @@ func main() {
bird.ClientConf = birdConf
bird.StatusConf = conf.Status
bird.RateLimitConf.Conf = conf.Ratelimit
bird.ParserConf = conf.Parser
endpoints.Conf = conf.Server
// Make server

View file

@ -19,6 +19,7 @@ type Config struct {
Status bird.StatusConfig
Bird bird.BirdConfig
Bird6 bird.BirdConfig
Parser bird.ParserConfig
}
// Try to load configfiles as specified in the files

View file

@ -50,4 +50,6 @@ listen = "0.0.0.0:29189"
config = "/etc/bird6.conf"
birdc = "birdc6"
[parser]
# Remove fields e.g. interface
filter_fields = []