-
Notifications
You must be signed in to change notification settings - Fork 672
Support for multiple responses in mDNS #559
Conversation
|
||
///////////////////////////////////////////////////////////// | ||
|
||
// simple IPv4 type that can be used as a key in a map (in contrast with net.IP), used for sets of IPs, etc... |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
func ipToIPv4(nip net.IP) IPv4 { ip := nip.To4(); return IPv4([4]byte{ip[0], ip[1], ip[2], ip[3]}) } | ||
|
||
// Parse an address (eg, "10.13.12.11") and return the corresponding IPv4 (eg, "10.13.12.11") | ||
func addrToIPv4(addr string) IPv4 { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@awh I have fixed the parsing mechanism for IP addresses as you suggested, and I have also added a unit test for that... |
It looks like a response containing multiple addresses is only permuted if the answer comes from the cache. Shouldn't |
In the case where |
@awh That's right: the presence of an entry locally ends the lookup. We currently do not support multiple responses to clients, so once you have a valid answer to the query, you are done. And regarding |
func (i Record) String() string { | ||
var buf bytes.Buffer | ||
if len(i.Name()) > 0 { | ||
buf.WriteString(fmt.Sprintf("%s", i.Name())) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
90ef2ac
to
7603180
Compare
…l possible responses from mDNS servers. Support for multiple responses from Lookup*() methods Support for multiple records when building packets with make*() methods Use a common "ZoneRecord" interface for structs that contain names and IPs
At first I thought you meant 'before this PR' by 'currently', but on closer reading I can see the PR widens all the interfaces to take a slice but still works with single values. Can you confirm my understanding that this PR doesn't change the user observed behaviour at all - it's just internal restructuring in support of future changes? |
@awh Exactly. This PR does not provide an user visible change. It only provides "insistent" queries at the mDNS layer, but they are not used at all in this PR... |
OK in that case LGTM. One final comment - and I really can't stress this enough - separating out different logical changes within your PRs into individual commits makes things much easier on the reviewer, with the consequence that things will get reviewed quicker. Perhaps each of your bullet points could have been teased out into different commits, and there are other things hiding in this PR too like the reformatting of the logging and moving the port binding into the start methods. I don't know how familiar you are with |
Support for multiple responses in mDNS
Thanks @awh Regarding how to organize the PR, I understand that it can get a bit messy because of the mix of different logical changes. But, in fact I usually do a I do that because my branches are in pending state for too long, and that means that I have to rebase master almost everyday (for keeping them mergeable in case the PR reviewer decides it can be merged). This daily rebase is really painful when the PR is more than 1 or 2 commits, but it is trivial when all changes have been squashed into only one commit... Please let me know of any way this workflow could be improved, but I've found this the only suitable solution for this project due to the long time it takes to have the PRs reviewed... |
please move this meta discussion to email. |
This pull request is the stepping stone for full support of multiple responses in WeaveDNS. It focuses in the mDNS client and server, where it provides
Lookups
(maybe not the best name): mDNS queries that try to obtain as many responses as possible for up to 500ms (and, in consequence, they block for that period of time). This will be used in the next PR by a "updater" process that will refresh the ZoneDb information by sending periodic queries to peers...Lookup*()
methodsZoneRecord
interface for many structs that contain names and IPs (used inLookup
methods, but also in the future database records)make*()
methods