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

bug: v1.2.12 responder errors and goes stale when a docker network is removed #51

Closed b-kamphorst closed 1 month ago

b-kamphorst commented 1 month ago

Hi @brutella,

I found another issue in v1.2.12, this time on the responder side. In particular, it gives an error if a network interface is removed. I run dnssd on Windows 11 in WSL2 (NAT network mode).

Expected behaviour

When I register a service and remove a Docker network, the responder should keep functioning. This is the behaviour in v1.2.11:

# # terminal 1, not in a container
# dnssd register -Name='myservice' -Port='123' -Type='_example._tcp'
Registering Service myservice._example._tcp.local. port 123
DATE: –––Thu Oct 3 2024–––
10:20:38.605    ...STARTING...
10:20:40.546    Got a reply for service myservice._example._tcp.local.: Name now registered and active
# # terminal 2
# docker network create test && docker network remove test
790e62e775547983d09986fb0e91405a2f330f5713a961bebbadc2b9406e9bbc
test

Everything remains alive.

Observed behaviour

When I register a service and create/remove/alter a Docker network, the responder throws an error and freezes (does not respond to Ctrl+C). This is the behaviour in v1.2.12:

# # terminal 1, not in a container
# dnssd register -Name='myservice' -Port='123' -Type='_example._tcp'
Registering Service myservice._example._tcp.local. port 123
DATE: –––Thu Oct 3 2024–––
10:25:13.864    ...STARTING...
10:25:15.729    Got a reply for service myservice._example._tcp.local.: Name now registered and active
# # terminal 2
# docker network create test && docker network remove test
fc78fd06f1f7e47ce67e24af70716bbdd13d99e60f6dcea6e1a2abfc4c831dda
test

Now the first terminal shows the following additional output:

# # terminal 1
INFO 2024/10/03 10:26:23 netlink_linux.go:30: route ip+net: no such network interface

The service no longer shows up on a fresh dnssd browse -Type='_example._tcp', nor does the terminal respond to Ctrl+C.

In this case the error is triggered by the docker network remove command, but I've observed the same behaviour when running a docker compose up command that should create/alter network interfaces (but not delete them).

Hope you can help!

brutella commented 1 month ago

Thanks for the report. Should be fixed now in master.

b-kamphorst commented 1 month ago

Wow, I'm impressed with the quick response + fix! It now shows the INFO message twice, but remains responsive as expected. Much appreciated 🙏

brutella commented 1 month ago

Happy to help. The info message is just there for informational purposes. 😉