fix: send mDNS queries on multicast sockets#162
Open
Solaris-star wants to merge 2 commits into
Open
Conversation
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes Have you signed the CLA already but the status is still pending? Recheck it. |
sendQuery only wrote to the multicast destination from unicast UDP sockets. Some devices only answer queries that originate on a multicast socket (RFC 6762). Send via ipv4MulticastConn / ipv6MulticastConn as well, while keeping the existing unicast writes so local loopback discovery tests still pass. Fixes hashicorp#144
tgross
self-requested a review
July 21, 2026 13:03
tgross
requested changes
Jul 21, 2026
tgross
left a comment
Member
There was a problem hiding this comment.
You haven't added tests or even bothered explaining how you've confirmed that this change works manually.
| var last error | ||
| if c.ipv4MulticastConn != nil { | ||
| if _, err = c.ipv4MulticastConn.WriteToUDP(buf, ipv4Addr); err != nil { | ||
| last = err |
Member
There was a problem hiding this comment.
You've changed the error handling behavior of this function without explaining why. We're now falling-thru on error to try another the unicast conn, but still returning the error, which seems like the worst of both worlds.
Address review feedback: - Do not return a partial write error if any socket succeeds - Only surface an error when every attempted write fails - Add unit tests covering multicast+unicast writes and partial failure
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) only from unicast sockets. Some devices (e.g. Alfen EV Charger) only respond to queries that originate on a multicast socket (RFC 6762).Fix
Also write queries via
ipv4MulticastConn/ipv6MulticastConn, while keeping the existing unicast writes so local loopback discovery continues to work.Tests
go test ./... -count=1Passes on this machine (including
TestServer_Lookup).Linked Issue
Closes #144