[PR #4574] [MERGED] [client] Implement DNS query caching in DNSForwarder #20725

Closed
opened 2026-08-05 05:07:37 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/4574
Author: @hakansa
Created: 10/2/2025
Status: Merged
Merged: 10/8/2025
Merged by: @mlsmaycon

Base: mainHead: feat/dns-fwd-cache


📝 Commits (7)

  • 815e6fd [client] Implement DNS query caching in DNSForwarder
  • dd1ee59 Fix cache get method to check for non-empty address slices
  • a928540 Normalize domain names in cache to ensure consistent casing and trailing dot usage
  • 3a40f69 Refactor cache methods to use slices.Clone for address slices
  • bdda31d cache nxdomain result
  • 2eefe14 Enhance DNSForwarder to handle NXDOMAIN responses when cache is empty
  • 7d69d65 Add cache unset method and remove stale cache entries in DNSForwarder

📊 Changes

4 files changed (+340 additions, -15 deletions)

View changed files

client/internal/dnsfwd/cache.go (+78 -0)
client/internal/dnsfwd/cache_test.go (+86 -0)
📝 client/internal/dnsfwd/forwarder.go (+87 -15)
📝 client/internal/dnsfwd/forwarder_test.go (+89 -0)

📄 Description

Describe your changes

[client] Implement DNS query caching in DNSForwarder

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/__


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/4574 **Author:** [@hakansa](https://github.com/hakansa) **Created:** 10/2/2025 **Status:** ✅ Merged **Merged:** 10/8/2025 **Merged by:** [@mlsmaycon](https://github.com/mlsmaycon) **Base:** `main` ← **Head:** `feat/dns-fwd-cache` --- ### 📝 Commits (7) - [`815e6fd`](https://github.com/netbirdio/netbird/commit/815e6fdba45e90cfd89d301844fc21abf0b710c9) [client] Implement DNS query caching in DNSForwarder - [`dd1ee59`](https://github.com/netbirdio/netbird/commit/dd1ee59e5ba6fb7730969b7c2dbbc62d94817638) Fix cache get method to check for non-empty address slices - [`a928540`](https://github.com/netbirdio/netbird/commit/a928540b01a4693caa5fff190401acc27b1f78b2) Normalize domain names in cache to ensure consistent casing and trailing dot usage - [`3a40f69`](https://github.com/netbirdio/netbird/commit/3a40f6991b810fb7043266aa9d5da69cd91865fe) Refactor cache methods to use slices.Clone for address slices - [`bdda31d`](https://github.com/netbirdio/netbird/commit/bdda31d7775dfe81315d94ea60b23ed841f0a9c4) cache nxdomain result - [`2eefe14`](https://github.com/netbirdio/netbird/commit/2eefe14be06fe3ca7212eac8909328006b9be5ed) Enhance DNSForwarder to handle NXDOMAIN responses when cache is empty - [`7d69d65`](https://github.com/netbirdio/netbird/commit/7d69d65b3610da38490682230ab31c8bf7e6e102) Add cache unset method and remove stale cache entries in DNSForwarder ### 📊 Changes **4 files changed** (+340 additions, -15 deletions) <details> <summary>View changed files</summary> ➕ `client/internal/dnsfwd/cache.go` (+78 -0) ➕ `client/internal/dnsfwd/cache_test.go` (+86 -0) 📝 `client/internal/dnsfwd/forwarder.go` (+87 -15) 📝 `client/internal/dnsfwd/forwarder_test.go` (+89 -0) </details> ### 📄 Description ## Describe your changes [client] Implement DNS query caching in DNSForwarder ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] 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](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] 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/__ --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 05:07:37 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#20725