feat(mdns): only send listening addresses that match interface #6003
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The current mDNS implementation always sends all current listen addresses in a
MdnsResponse
, independent of whether they match the interface that we receive aMdnsQuery
on.This is causing multiple issues, e.g.:
And as noted in #5790, it also violates the mDNS specs.
This PR changes
libp2p-mdns
to only reply to aMdnsQuery
with the listen addresses that match the IP of the interface that we received the query on.Implementation-wise, this is solved by providing each interface-task only with the subset of listening addresses that match the interface IP.
Fixes: #5995
Related: #5790
Notes & open questions
Because each interface-task now has a different list of listening addresses that it will send out, I think it doesn't make sense anymore to have a single shared list of listening addresses. Instead, I've changed the implementation to only provide each interface-task with the listening addresses that match the interface's IP, and use a channel for informing the task about relevant listening address updates.
cc @MathJud @T-X @MatthiasvB
Change checklist