mirror of
https://github.com/alice-lg/birdwatcher.git
synced 2025-03-09 00:00:05 +01:00
added bird cmd (fixes #1)
This commit is contained in:
parent
07a02dcc24
commit
4c0a82417f
3 changed files with 10 additions and 2 deletions
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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}, "")
|
||||
|
|
Loading…
Add table
Reference in a new issue