-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically determine what address to advertise, per-interface #180
base: master
Are you sure you want to change the base?
Automatically determine what address to advertise, per-interface #180
Conversation
Basically create_sockets has been renamed refresh_sockets, and moved into the Zeroconf class. It can now check for changes and only refresh if needed. We poll every 3 minutes from within the engine loop to detect changes. In addition, when we get an error in send_from(), we assume that it's due to network changes, refresh the sockets, and retry with all new sockets if we were multicasting something.
@EternityForest Looks like this has gone stale. Are you still intrested in working on this? |
i would like this support, I ahve to hack support and kill zeroconf on interface changes! |
Huh, totally forgot all about this branch. Maybe it's time to revisit it! |
That would be great. Things have changed a bit since this PR so there is probably a bit of refactor needed |
I've made a bit of progress on this, but a lot has changed since then and the new code seems much more procedural and right on the edge of my ability to understand any of it. I think this PR itself isn't worth much anymore, and it would be more of a start from scratch kind of thing. |
This is a rather large change, but it solves a fairly big usability issue.
If you have multiple interfaces, manually supplying a list of IPs isn't enough, as we do not want to advertise the WiFi IP to the Ethernet interface, etc.
Even allowing per-interface lists of IPs causes trouble, as IP addresses can change, and one would have to track that manually.
Besides that, it's nontrivial to get your own addresses if you don't already have it, and having to add a dozen lines or so for something so common seems wasteful.
My proposed solution is to allow None as an address, which is automatically replaced with the IP of whatever device the packet is being sent from. To do this I have bound all the sockets to the individual devices(Other than the listen socket), so that we can send multicasts to specific interfaces.
This causes another problem, in that relying on per-device sockets gets messy when things are dynamic. I resolve this problem by recreating the sockets if the list of interfaces changes. To do this I poll every 3 minutes, but I also refresh the list and retry if a send fails.
This patch has a slight performance hit I'd imagine, because every response now requires "recompiling" the response packet bytes, but MDNS isn't exactly a high datarate application as it is.
Thanks for your time!!