trivial fixes

This commit is contained in:
Jordan Whited 2020-05-15 13:01:58 -07:00
parent 53c1794798
commit 5c7c582a2a
2 changed files with 7 additions and 2 deletions

View File

@ -26,11 +26,12 @@ var (
) )
func main() { func main() {
flag.Parse()
if len(*deviceFlag) < 1 { if len(*deviceFlag) < 1 {
log.Fatal("missing device flag") log.Fatal("missing device flag")
} }
if len(*dnsZoneFlag) < 1 { if len(*dnsZoneFlag) < 1 {
log.Fatal("missing dns flag") log.Fatal("missing zone flag")
} }
resolver := net.DefaultResolver resolver := net.DefaultResolver
if len(*dnsServerFlag) > 0 { if len(*dnsServerFlag) > 0 {
@ -59,6 +60,10 @@ func main() {
"error retrieving Wireguard device '%s' info: %v", "error retrieving Wireguard device '%s' info: %v",
*deviceFlag, err) *deviceFlag, err)
} }
if len(wgDevice.Peers) < 1 {
log.Println("no peers found")
os.Exit(0)
}
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
defer cancel() defer cancel()
done := make(chan struct{}) done := make(chan struct{})

View File

@ -142,7 +142,7 @@ func (p *WGSD) ServeDNS(ctx context.Context, w dns.ResponseWriter,
} }
func getHostRR(pubKey, zone string, endpoint *net.UDPAddr) dns.RR { func getHostRR(pubKey, zone string, endpoint *net.UDPAddr) dns.RR {
if endpoint.IP == nil { if endpoint == nil || endpoint.IP == nil {
return nil return nil
} }
name := fmt.Sprintf("%s.%s", strings.ToUpper(pubKey), zone) name := fmt.Sprintf("%s.%s", strings.ToUpper(pubKey), zone)