2016-12-22 02:09:02 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
2017-01-29 21:14:40 +00:00
|
|
|
"net"
|
2016-12-22 02:09:02 +00:00
|
|
|
"os"
|
2017-01-29 21:14:40 +00:00
|
|
|
"time"
|
|
|
|
|
2017-03-03 15:19:35 +00:00
|
|
|
"github.com/FreifunkBremen/yanic/respond"
|
2017-04-10 16:54:12 +00:00
|
|
|
"github.com/FreifunkBremen/yanic/runtime"
|
2016-12-22 02:09:02 +00:00
|
|
|
)
|
|
|
|
|
2017-04-19 21:52:13 +00:00
|
|
|
// Usage: yanic-query wlp4s0 "[fe80::eade:27ff:dead:beef%wlp4s0]:1001"
|
2016-12-22 02:09:02 +00:00
|
|
|
func main() {
|
|
|
|
iface := os.Args[1]
|
|
|
|
dstAddress := os.Args[2]
|
|
|
|
|
|
|
|
log.Printf("Sending request address=%s iface=%s", dstAddress, iface)
|
|
|
|
|
2017-04-10 16:54:12 +00:00
|
|
|
nodes := runtime.NewNodes(&runtime.Config{})
|
2016-12-22 02:09:02 +00:00
|
|
|
|
2017-06-29 17:06:53 +00:00
|
|
|
collector := respond.NewCollector(nil, nodes, iface, iface, iface, 0)
|
|
|
|
collector.SendPacket(net.UDPAddr{
|
|
|
|
IP: net.ParseIP(dstAddress),
|
|
|
|
Zone: iface,
|
|
|
|
})
|
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()
|
|
|
|
}
|