-
Notifications
You must be signed in to change notification settings - Fork 178
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
fix(iroh): Parse DNS answer with multiple records into a proper NodeAddr
#3104
Conversation
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3104/docs/iroh/ Last updated: 2025-01-08T15:58:04Z |
the reasons is likely, that we "know" what we expect to publish here, but I agree we probably want to be more relaxed here, and just log invalid entries |
ensure!( | ||
&records.all(|(n, _)| n == node_id), | ||
"invalid DNS answer: all _iroh txt records must belong to the same node domain" | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This records.all
call was the culprit: It takes &mut self
, and records
is an impl Iterator
, so it actually drains all remaining items.
Then below, the empty iterator is .chain
ed with the first item.
I verified that this fixes the issue connecting between me and flub using |
Description
Running
iroh-doctor
this morning with flub I wasn't able to connect. Flub was on iroh 0.30, I was on iroh main (commit c650ea8).I noticed this in the logs:
"no relay URL"? Even though the DNS record clearly contains one.
From the logs it showed that the
DiscoveryItem
didn't contain all information from the DNS answer.This PR adds a test that initially failed - it only parsed the first TXT record out of the DNS answer, because of a call to
records.all
, which drained the iterator of all remaining items.It also fixes this bug by avoiding a call to
.all
.Breaking Changes
None.
Notes & open questions
I tried to avoid functional changes besides the bugfix. But, all of this parsing code makes me think of Postel's Law / the robustness principle: Instead of erroring out when we see conflicting information - should we filter out non-matching answer records?
There seems to be some difference between
from_pkarr_signed_packet
andfrom_hickory_records
: The former is very lenient in what it parses, the latter is very strict and opts to error out when something's amiss.Change checklist