From ed6e67fa134a4ab5c9451d91e4f3258a63e071e3 Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Thu, 22 Dec 2016 03:09:02 +0100 Subject: [PATCH] Add small query command --- cmd/respond-query/main.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 cmd/respond-query/main.go diff --git a/cmd/respond-query/main.go b/cmd/respond-query/main.go new file mode 100644 index 0000000..15382b6 --- /dev/null +++ b/cmd/respond-query/main.go @@ -0,0 +1,31 @@ +package main + +import ( + "log" + "os" + + "github.com/FreifunkBremen/respond-collector/models" + "github.com/FreifunkBremen/respond-collector/respond" + "time" +) + +// Usage: respond-query wlp4s0 "[fe80::eade:27ff:dead:beef%wlp4s0]:1001" +func main() { + iface := os.Args[1] + dstAddress := os.Args[2] + + log.Printf("Sending request address=%s iface=%s", dstAddress, iface) + + nodes := models.NewNodes(&models.Config{}) + + collector := respond.NewCollector(nil, nodes, iface) + collector.SendPacket(dstAddress) + + time.Sleep(time.Second) + + for id, data := range nodes.List { + log.Printf("%s: %+v", id, data) + } + + collector.Close() +}