diff --git a/bird/bird.go b/bird/bird.go index 1e1fa10..c5c2a3d 100644 --- a/bird/bird.go +++ b/bird/bird.go @@ -5,10 +5,12 @@ import ( "strings" ) +var BirdCmd string + func Run(args string) ([]byte, error) { args = "show " + args argsList := strings.Split(args, " ") - return exec.Command("birdc", argsList...).Output() + return exec.Command(BirdCmd, argsList...).Output() } func RunAndParse(cmd string, parser func([]byte) Parsed) Parsed { diff --git a/bird/parser.go b/bird/parser.go index 4a04cf1..e09674a 100644 --- a/bird/parser.go +++ b/bird/parser.go @@ -116,7 +116,7 @@ func mainRouteDetail(groups []string, route Parsed) Parsed { route["age"] = groups[5] route["learnt_from"] = groups[6] route["primary"] = groups[7] == "*" - route["metric"] = parseInt(groups[8]) + route["metric"] = parseInt(groups[8]) return route } diff --git a/birdwatcher.go b/birdwatcher.go index 18cd65b..89b84b6 100644 --- a/birdwatcher.go +++ b/birdwatcher.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/julienschmidt/httprouter" + "github.com/mchackorg/birdwatcher/bird" "github.com/mchackorg/birdwatcher/endpoints" ) @@ -31,8 +32,13 @@ func main() { port := flag.String("port", "29184", "The port the birdwatcher should run on") + birdc := flag.String("birdc", + "birdc", + "The birdc command to use (for IPv6, use birdc6)") flag.Parse() + bird.BirdCmd = *birdc + r := makeRouter() realPort := strings.Join([]string{":", *port}, "")