-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Handshake resolver support #466
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
Conversation
📝 WalkthroughWalkthroughThe change updates DNS resolution in internal/dns/dns.go to add Handshake-based fallback lookups. If Cardano Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Areas requiring extra attention:
Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
No issues found across 1 file
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
internal/dns/dns.go (3)
128-139: Consider checkinglen(records) == 0for consistency.The condition
records == nilmay not trigger the Handshake fallback ifLookupRecordsreturns an empty slice[]Record{}instead ofnil. Later infindNameserversForDomain(line 437), the code useslen(nsRecords) > 0which handles both cases.- if records == nil { + if len(records) == 0 {
134-136: Differentiate error messages for better observability.The error message is identical to the Cardano lookup error (line 123), making it difficult to distinguish which lookup source failed when debugging.
slog.Error( - fmt.Sprintf("failed to lookup records in state: %s", err), + fmt.Sprintf("failed to lookup Handshake records: %s", err), )
455-478: Code duplication with Cardano NS lookup block.This block is structurally identical to the Cardano lookup above (lines 437-454), differing only in the function calls (
LookupHandshakeRecordsvsLookupRecords).This is acceptable for now given the straightforward logic, but if more resolver sources are added, consider extracting a helper function that accepts a lookup function as a parameter to reduce duplication.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal/dns/dns.go(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
internal/dns/dns.go (1)
internal/state/state.go (1)
GetState(452-454)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: docker
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (actions)
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
internal/dns/dns.go (1)
116-139: LGTM on the overall Handshake fallback pattern.The implementation correctly establishes Cardano as the primary resolver with Handshake as a fallback. The error handling appropriately mirrors the existing Cardano error handling, and the early return on error prevents cascading failures.
Signed-off-by: Aurora Gaffney <aurora@blinklabs.io>
eb62060 to
e757251
Compare
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
internal/dns/dns.go (1)
431-478: Duplicated NS/A/AAAA resolution for Cardano vs Handshake — candidate for small helperThe Handshake NS branch is effectively a copy of the Cardano branch with
LookupHandshakeRecordssubstituted and the samenet.ParseIP+ aggregation logic. This is fine functionally, but it does mean any future change to how you buildret(e.g., validatingParseIPresults, supporting additional RR types, TTL handling) must be done in two places.If this area evolves further, consider extracting a helper that takes a lookup function and the domain name to resolve NS → A/AAAA, e.g.:
type recordLookupFn func([]string, string) ([]state.DomainRecord, error) func resolveOnChainNS(lookup recordLookupFn, domain string) (string, map[string][]net.IP, error) { nsRecords, err := lookup([]string{"NS"}, domain) if err != nil || len(nsRecords) == 0 { return "", nil, err } ret := map[string][]net.IP{} for _, nsRecord := range nsRecords { aRecords, err := lookup([]string{"A", "AAAA"}, nsRecord.Rhs) if err != nil { return "", nil, err } for _, aRecord := range aRecords { ip := net.ParseIP(aRecord.Rhs) if ip != nil { ret[nsRecord.Rhs] = append(ret[nsRecord.Rhs], ip) } } } return dns.Fqdn(domain), ret, nil }Then
findNameserversForDomaincan call it once for Cardano and once for Handshake, keeping behavior in sync and reducing duplication.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal/dns/dns.go(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
internal/dns/dns.go (1)
internal/state/state.go (1)
GetState(452-454)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
internal/dns/dns.go (1)
115-140: This review comment is based on an incorrect assumption about the return value semantics ofLookupRecordsandLookupHandshakeRecords. Both functions explicitly returnnil(not an empty slice) when no records are found, as confirmed by thelookupRecordsimplementation which returnsnil, nilwhenlen(ret) == 0. The existing code usingrecords == nilchecks is semantically correct and aligns with the actual behavior. The suggested change tolen(records) == 0would not be an improvement and misrepresents how these functions work.Likely an incorrect or invalid review comment.
Closes #263
Summary by cubic
Add Handshake resolver support as a fallback when Cardano records are missing. This improves DNS query handling and nameserver discovery for domains resolved via Handshake.
Written for commit e757251. Summary will update automatically on new commits.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.