brutella / dnssd

This library implements Multicast DNS (mDNS) and DNS-Based Service Discovery (DNS-SD) for Zero Configuration Networking in Go.
MIT License
207 stars 33 forks source link

Browse in refactoring branch is broken for windows #28

Closed makon closed 3 years ago

makon commented 3 years ago

Unfortunately setting a control message is not supported for windows, see here: https://github.com/golang/net/blob/master/ipv6/control_windows.go

So a Request struct will never have a iface. It will always be nil: https://github.com/brutella/dnssd/blob/0d9d12fe7a9f5556afb42de4d7cd81884871d417/mdns.go#L222

This leads to a nil pointer exception at: https://github.com/brutella/dnssd/blob/0d9d12fe7a9f5556afb42de4d7cd81884871d417/browse.go#L72

And it will never notify about any service because the ifaceIPs dictionary is always empty for windows: https://github.com/brutella/dnssd/blob/0d9d12fe7a9f5556afb42de4d7cd81884871d417/browse.go#L79

brutella commented 3 years ago

Thanks

makon commented 3 years ago

Thx for the fix.

I guess I wasn't clear on the issue. So the main issue on windows is that it will never notify about any service because the ifaceIPs dictionary is always empty for windows.

The root cause is that golang does not support control messages on windows, so you will never receive the interface information. Hence the ifaceIPs dictionary is always empty. Not sure what is the best solution for that case. I hope this was more clear

brutella commented 3 years ago

Maybe you could use the Config.IPs field to workaround this limitation. But this is not recommended because of #8