[PR #79] wg-quick: darwin: avoid redundant DNS preference writes #79

Open
opened 2026-10-25 04:18:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amneziawg-tools/pull/79
Author: @mikhalytch
Created: 10/20/2026
Status: 🔄 Open

Base: master ← Head: fix/darwin-dns-idempotence


📝 Commits (1)

  • f9284ee wg-quick: darwin: avoid redundant DNS preference writes

📊 Changes

1 file changed (+17 additions, -6 deletions)

View changed files

📝 src/wg-quick/darwin.bash (+17 -6)

📄 Description

Context / Why

The Darwin route monitor calls set_dns() repeatedly. It currently rewrites DNS servers and search domains even when their values are unchanged, generating unnecessary SystemConfiguration notifications.

On an M1 Pro Mac with macOS 27.0.1, airportd sustained approximately 100–115% CPU. After this change, with the same CLI VPN connection active, it settled at 0.3–0.4%.

What changed

  • Read current DNS servers and search domains before updating them.
  • Write only settings whose values differ.
  • Continue correcting external DNS changes and restoring the original settings on disconnect.

Files / Areas to focus

  • src/wg-quick/darwin.bash: set_dns().
  • Comparisons of ordered DNS lists and empty search-domain lists.
  • Preservation of the existing original-settings cache used for cleanup.

Risk assessment

The change is limited to Darwin DNS updates. Rollback consists of reverting this commit.

How to test

  • Bash syntax check passed.
  • Four DNS regression tests passed against the patched upstream script: repeated updates, selective writes, external changes, and restoration of automatic DNS for newly discovered services.
  • With the CLI VPN connected, the final 60-second observation recorded no airportd configuration callbacks or interface refreshes. DNS resolution and HTTPS access succeeded.

Notes

Reference implementation and regression tests:
github.com/mikhalytch/amneziawg-mac@8f8d19e2ea

The regression tests are maintained in the reference repository; this PR changes only the upstream Darwin script.


🔄 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/amnezia-vpn/amneziawg-tools/pull/79 **Author:** [@mikhalytch](https://github.com/mikhalytch) **Created:** 10/20/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `fix/darwin-dns-idempotence` --- ### 📝 Commits (1) - [`f9284ee`](https://github.com/amnezia-vpn/amneziawg-tools/commit/f9284ee733ffc69be5153f6760bbd7bcd273b884) wg-quick: darwin: avoid redundant DNS preference writes ### 📊 Changes **1 file changed** (+17 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/wg-quick/darwin.bash` (+17 -6) </details> ### 📄 Description **Context / Why** The Darwin route monitor calls set_dns() repeatedly. It currently rewrites DNS servers and search domains even when their values are unchanged, generating unnecessary SystemConfiguration notifications. On an M1 Pro Mac with macOS 27.0.1, airportd sustained approximately 100–115% CPU. After this change, with the same CLI VPN connection active, it settled at 0.3–0.4%. **What changed** - Read current DNS servers and search domains before updating them. - Write only settings whose values differ. - Continue correcting external DNS changes and restoring the original settings on disconnect. **Files / Areas to focus** - src/wg-quick/darwin.bash: set_dns(). - Comparisons of ordered DNS lists and empty search-domain lists. - Preservation of the existing original-settings cache used for cleanup. **Risk assessment** The change is limited to Darwin DNS updates. Rollback consists of reverting this commit. **How to test** - Bash syntax check passed. - Four DNS regression tests passed against the patched upstream script: repeated updates, selective writes, external changes, and restoration of automatic DNS for newly discovered services. - With the CLI VPN connected, the final 60-second observation recorded no airportd configuration callbacks or interface refreshes. DNS resolution and HTTPS access succeeded. **Notes** Reference implementation and regression tests: https://github.com/mikhalytch/amneziawg-mac/commit/8f8d19e2eac0be30ce81c9be53dd6f8304082e55 The regression tests are maintained in the reference repository; this PR changes only the upstream Darwin script. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amneziawg-tools#79
No description provided.