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.
orion/cmd/discovery/main.go

42 lines
647 B
Go
Raw Permalink Normal View History

package main
import (
"context"
"flag"
"log"
"time"
"forge.cadoles.com/Pyxis/orion/emlid"
)
var (
timeout = 10 * time.Second
)
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)
}
}