Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

EternityForest
Copy link

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!!

Daniel Dunn added 3 commits July 4, 2019 08:50
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.
@bdraco
Copy link
Member

bdraco commented Jun 22, 2021

@EternityForest Looks like this has gone stale. Are you still intrested in working on this?

@seandepagnier
Copy link

i would like this support, I ahve to hack support and kill zeroconf on interface changes!

@EternityForest
Copy link
Author

EternityForest commented Jan 8, 2022

Huh, totally forgot all about this branch. Maybe it's time to revisit it!

@bdraco
Copy link
Member

bdraco commented Jan 8, 2022

That would be great. Things have changed a bit since this PR so there is probably a bit of refactor needed

@EternityForest
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants