This repository has been archived on 2024-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
2018-10-16 15:23:16 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"flag"
|
|
|
|
"log"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"forge.cadoles.com/Pyxis/orion/emlid"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2019-03-27 18:50:35 +01:00
|
|
|
timeout = 10 * time.Second
|
2018-10-16 15:23:16 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
flag.DurationVar(&timeout, "timeout", timeout, "mDNS scan timeout")
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
log.Println("Searching for ReachRS services on network...")
|
|
|
|
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
services, err := emlid.Discover(ctx)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, s := range services {
|
|
|
|
log.Println("Found:")
|
|
|
|
log.Printf(" Name: '%s'", s.Name)
|
|
|
|
log.Printf(" Hosts: %s", s.AddrV4)
|
|
|
|
log.Printf(" Port: '%d'", s.Port)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|