schollz / peerdiscovery

Pure-Go library for cross-platform local peer discovery using UDP multicast :woman: :repeat: :woman:
MIT License
644 stars 56 forks source link

Ignoring configured address family can lead to deadlock on MacOS #23

Closed thewilli closed 3 years ago

thewilli commented 3 years ago

After getting the list of interfaces, interfaces not having at least one address of the configured address family are not skipped.

Sending a multicast with an IPv4 connection on an IPv6-only interface results (at least on MacOS) in a deadlock.

Additionally, you should check the interface flags if is up and if it supports multicast at all.

This issue might be the root cause of https://github.com/schollz/croc/issues/313

schollz commented 3 years ago

maybe this will fix it: https://github.com/schollz/peerdiscovery/compare/v1.6.3...v1.6.4#diff-2579afdfe9dbc2fd03f59fa3dd5f31396c4107cf1ca5c05afe433f163a00c276R171-R201 ?

thewilli commented 3 years ago

please consider #24 which might be a bit more straightforward and moves the code out of the function to improve readability

schollz commented 3 years ago

Does it fix the issue?

thewilli commented 3 years ago

it does for me 😉 and it reduces some overhead as almost all of my 19 network interfaces were skipped

schollz commented 3 years ago

That's great! Thanks for the update. Merged and added to croc

thewilli commented 3 years ago

fixed by #24