[PR #3140] fix: flush dns cache instead of restarting the resolver #3099

Open
opened 2026-10-14 21:07:29 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amnezia-client/pull/3140
Author: @SPTApyo
Created: 9/7/2026
Status: 🔄 Open

Base: dev ← Head: fix/linux-dns-cache-flush


📝 Commits (2)

  • 2dde645 fix: flush dns cache instead of restarting the resolver
  • 17f96ba refactor: drop dead logging branch and repeated splits

📊 Changes

3 files changed (+20 additions, -15 deletions)

View changed files

📝 client/platforms/linux/daemon/linuxfirewall.cpp (+0 -2)
📝 service/server/killswitch.cpp (+5 -5)
📝 service/server/router_linux.cpp (+15 -8)

📄 Description

RouterLinux::flushDns restarts the whole resolver service, and it is called on every connect and every disconnect from VpnConnection. Restarting systemd-resolved drops the DNS cache for the entire machine and briefly breaks name resolution for every other process, which is a lot more than flushing the VPN's stale entries needs to do.

It now calls resolvectl flush-caches, which does exactly that job without a restart. It has been available since systemd 239. The nscd branch uses nscd -i hosts for the same reason, and systemd-resolved is checked first since it is the resolver in use on current systems.

The result of the command is also checked now. The previous version returned true unconditionally, so the "Failed to flush DNS" branch in the caller was unreachable even when the command failed.

Second commit is unrelated cleanup in the same area: a dead else if (false) logging branch in LinuxFirewall::execute, and a loop in killswitch that called split('/') three times per entry.


🔄 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/amnezia-client/pull/3140 **Author:** [@SPTApyo](https://github.com/SPTApyo) **Created:** 9/7/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/linux-dns-cache-flush` --- ### 📝 Commits (2) - [`2dde645`](https://github.com/amnezia-vpn/amnezia-client/commit/2dde645cf1798d6b5123836542546e37f1e63d81) fix: flush dns cache instead of restarting the resolver - [`17f96ba`](https://github.com/amnezia-vpn/amnezia-client/commit/17f96baf640a9914710b21e9c7e2318397d5e5cf) refactor: drop dead logging branch and repeated splits ### 📊 Changes **3 files changed** (+20 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `client/platforms/linux/daemon/linuxfirewall.cpp` (+0 -2) 📝 `service/server/killswitch.cpp` (+5 -5) 📝 `service/server/router_linux.cpp` (+15 -8) </details> ### 📄 Description RouterLinux::flushDns restarts the whole resolver service, and it is called on every connect and every disconnect from VpnConnection. Restarting systemd-resolved drops the DNS cache for the entire machine and briefly breaks name resolution for every other process, which is a lot more than flushing the VPN's stale entries needs to do. It now calls `resolvectl flush-caches`, which does exactly that job without a restart. It has been available since systemd 239. The nscd branch uses `nscd -i hosts` for the same reason, and systemd-resolved is checked first since it is the resolver in use on current systems. The result of the command is also checked now. The previous version returned true unconditionally, so the "Failed to flush DNS" branch in the caller was unreachable even when the command failed. Second commit is unrelated cleanup in the same area: a dead `else if (false)` logging branch in LinuxFirewall::execute, and a loop in killswitch that called `split('/')` three times per entry. --- <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/amnezia-client#3099
No description provided.