Skip to content

Conversation

@lixmal
Copy link
Collaborator

@lixmal lixmal commented Dec 1, 2025

Describe your changes

In some cases the resolver returns IPv4-mapped IPv6 addresses, which incorrectly translate to broken records.
This PR fixes that.

Issue ticket number and link

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved DNS address resolution to ensure consistent handling and standardization of IPv6 addresses in all DNS operations.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 1, 2025

Walkthrough

IPv4-mapped IPv6 addresses are being normalized in DNSForwarder.handleDNSQuery by applying an Unmap() operation after IP resolution. This normalization is applied consistently across internal state updates, response construction, and caching operations.

Changes

Cohort / File(s) Summary
IPv4-mapped IPv6 address normalization
client/internal/dnsfwd/forwarder.go
DNSForwarder.handleDNSQuery now unmaps IPv4-mapped IPv6 addresses using Unmap() after resolution, applying this normalization to state, response, and cache layers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify Unmap() is applied at all relevant points in the query handling flow
  • Confirm address normalization doesn't break existing cache lookups or state comparisons
  • Check for any edge cases where mapped addresses might still propagate through alternate paths

Poem

🐰 A mapped address hops through the DNS,
But now we unmask it before it's immense,
IPv6 dressed as four becomes plain,
Standard and clean—no more the chain,
Hopping and caching with clarity's gain!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the bug fix for DNS forwarder handling IPv4-mapped IPv6 addresses, which aligns with the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description covers the core change and correctly identifies it as a bug fix, but lacks an issue ticket number and explanation for why documentation is not needed.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-dns-forwarder-4in6

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 1, 2025

@lixmal lixmal merged commit 3f4f825 into main Dec 5, 2025
50 of 54 checks passed
@lixmal lixmal deleted the fix-dns-forwarder-4in6 branch December 5, 2025 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants