fix: send mDNS queries from multicast sockets - #167
Open
BetterAndBetterII wants to merge 1 commit into
Open
BetterAndBetterII wants to merge 1 commit into
BetterAndBetterII wants to merge 1 commit into
Conversation
sendQuery wrote to the multicast destination from ephemeral unicast sockets. Some devices ignore those queries. Write from the multicast sockets (UDP source port 5353) instead, and enable multicast loopback so same-host discovery still works. Fixes hashicorp#144
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
sendQuerysent mDNS queries to the multicast destination (224.0.0.251/ff02::fb) from ephemeral unicast sockets. Some devices only answer queries that originate on a multicast socket bound to UDP port 5353 (RFC 6762).This change writes queries from
ipv4MulticastConn/ipv6MulticastConninstead, and enables multicast loopback on those sockets so same-host discovery (Lookup/ local server) still works.Related Issue
Fixes #144
How Has This Been Tested?
go test -count=1 -timeout=60s ./...Includes a new regression test (
TestSendQuery_UsesMulticastSocket) that closes the unicast socket and asserts the query still arrives from the multicast socket's source port. ExistingTestServer_Lookupcontinues to pass with multicast loopback enabled.Contributor Checklist
and followed the AI usage guide.