diff --git a/cmd/client/main.go b/cmd/client/main.go index 43cac71..6755904 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -26,11 +26,12 @@ var ( ) func main() { + flag.Parse() if len(*deviceFlag) < 1 { log.Fatal("missing device flag") } if len(*dnsZoneFlag) < 1 { - log.Fatal("missing dns flag") + log.Fatal("missing zone flag") } resolver := net.DefaultResolver if len(*dnsServerFlag) > 0 { @@ -59,6 +60,10 @@ func main() { "error retrieving Wireguard device '%s' info: %v", *deviceFlag, err) } + if len(wgDevice.Peers) < 1 { + log.Println("no peers found") + os.Exit(0) + } ctx, cancel := context.WithCancel(context.Background()) defer cancel() done := make(chan struct{}) diff --git a/wgsd.go b/wgsd.go index 5922ef3..0e27bb7 100644 --- a/wgsd.go +++ b/wgsd.go @@ -142,7 +142,7 @@ func (p *WGSD) ServeDNS(ctx context.Context, w dns.ResponseWriter, } func getHostRR(pubKey, zone string, endpoint *net.UDPAddr) dns.RR { - if endpoint.IP == nil { + if endpoint == nil || endpoint.IP == nil { return nil } name := fmt.Sprintf("%s.%s", strings.ToUpper(pubKey), zone)