yanic/cmd/yanic-query/main.go

33 lines
620 B
Go
Raw Normal View History

2016-12-22 02:09:02 +00:00
package main
import (
"log"
"net"
2016-12-22 02:09:02 +00:00
"os"
"time"
2017-03-03 15:19:35 +00:00
"github.com/FreifunkBremen/yanic/respond"
"github.com/FreifunkBremen/yanic/runtime"
2016-12-22 02:09:02 +00:00
)
// 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 := runtime.NewNodes(&runtime.Config{})
2016-12-22 02:09:02 +00:00
collector := respond.NewCollector(nil, nodes, iface, 0)
collector.SendPacket(net.ParseIP(dstAddress))
2016-12-22 02:09:02 +00:00
time.Sleep(time.Second)
for id, data := range nodes.List {
log.Printf("%s: %+v", id, data)
}
collector.Close()
}