fix: mDNS lookup

This commit is contained in:
nyyu 2023-03-06 20:44:56 +01:00
parent 95eedc417b
commit a4e2d54457

View File

@ -124,13 +124,6 @@ func (f *FreeboxAPIVersion) newFreeboxAPIVersionMDNS(*FreeboxHttpClient) error {
// mDNS lookup
go func() {
defer close(entries)
if err := mdns.Lookup(mdnsService, entries); err != nil {
log.Error.Println("mDNS lookup failed:", err)
}
log.Debug.Println("End of mDNS lookup")
}()
for entry := range entries {
deviceName := entry.Name
idx := strings.Index(deviceName, ".")
@ -166,12 +159,16 @@ func (f *FreeboxAPIVersion) newFreeboxAPIVersionMDNS(*FreeboxHttpClient) error {
default:
}
}
if f.IsValid() {
return nil
}
}
}()
return errors.New("MDNS timeout")
if err := mdns.Lookup(mdnsService, entries); err != nil {
log.Error.Println("mDNS lookup failed:", err)
return err
}
log.Debug.Println("End of mDNS lookup")
close(entries)
return nil
}
func (f *FreeboxAPIVersion) setQueryApiVersion(forceApiVersion int) error {