[PR #3251] fix(ui): allow saving an empty primary DNS #3149

Open
opened 2026-10-15 04:07:50 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amnezia-client/pull/3251
Author: @ChesterFishmansWork
Created: 10/2/2026
Status: 🔄 Open

Base: dev ← Head: fix/3190-empty-primary-dns


📝 Commits (5)

  • 35185a0 fix(ui): allow saving an empty primary DNS
  • 283ae07 fix(dns): keep an empty DNS setting out of the platform resolvers
  • f80269d fix(dns): close review findings (OpenVPN/iptables/export/platform paths)
  • d4a90bb fix(dns): round-2 review follow-ups (ipsec script, root-script validation, platform symmetry)
  • 80770fd fix(ui): allow saving an empty primary DNS

📊 Changes

27 files changed (+435 additions, -95 deletions)

View changed files

📝 client/android/protocolApi/src/main/kotlin/Protocol.kt (+2 -1)
📝 client/android/utils/src/main/kotlin/net/NetworkUtils.kt (+25 -0)
📝 client/android/wireguard/src/main/kotlin/org/amnezia/vpn/protocol/wireguard/Wireguard.kt (+8 -6)
📝 client/android/xray/src/main/kotlin/Xray.kt (+3 -6)
📝 client/core/configurators/configuratorBase.cpp (+74 -3)
📝 client/core/configurators/configuratorBase.h (+10 -1)
📝 client/core/configurators/openVpnConfigurator.cpp (+17 -6)
📝 client/core/configurators/wireguardConfigurator.cpp (+4 -2)
📝 client/core/controllers/selfhosted/installController.cpp (+7 -1)
📝 client/core/protocols/xrayProtocol.cpp (+19 -6)
📝 client/core/utils/constants/protocolConstants.h (+4 -0)
📝 client/core/utils/selfhosted/scriptsRegistry.cpp (+15 -4)
📝 client/daemon/daemon.cpp (+30 -6)
📝 client/daemon/interfaceconfig.cpp (+13 -9)
📝 client/mozilla/localsocketcontroller.cpp (+10 -4)
📝 client/platforms/ios/PacketTunnelProvider+WireGuard.swift (+4 -0)
📝 client/platforms/ios/PacketTunnelProvider+Xray.swift (+17 -5)
📝 client/platforms/ios/WGConfig.swift (+19 -4)
📝 client/platforms/ios/ios_controller.mm (+32 -8)
📝 client/platforms/linux/daemon/dnsutilslinux.cpp (+10 -0)

...and 7 more files

📄 Description

Problem

The Save handler in the DNS settings page refuses an empty Primary DNS field, so a configuration that must not push any DNS server through the tunnel (split tunneling only, or "keep whatever the server advertises") cannot be stored at all:

if (primaryDns.textField.text === "") {
    primaryDns.errorText = qsTr("Primary DNS cannot be empty")
    return
}

Fixes #3190.

Change

client/ui/qml/Pages2/PageSettingsDns.qml — drop the empty-value check in the Save handler. Input validation of the field itself (IP regexp) is untouched.

⚠️ Known gap / open question

The UI part is small, but an independent review of the full data path found that an empty primaryDns is not handled consistently downstream — unlike secondaryDns, which is guarded in several places. If an empty primary DNS is the intended semantics, the following places should probably be fixed as well (happy to extend this PR or split them into a separate one once the expected behaviour is confirmed):

  • client/core/protocols/xrayProtocol.cpp:37-42 — m_dnsServers.push_back(QHostAddress(primaryDns)) is unconditional; an empty string becomes a null QHostAddress that is later passed to iface->updateResolvers(tunName, m_dnsServers).
  • client/daemon/daemon.cpp:172 — resolvers.append(QHostAddress(config.m_primaryDnsServer)) is unconditional, while the secondary on the next line is guarded by isEmpty(). An empty primary therefore reaches updateResolvers and is written as an empty entry into systemd-resolved / macOS ServerAddresses.
  • client/vpnConnection.cpp:135-145 — routeAddList(..., QStringList() << dns1 << dns2) for non-WireGuard containers (OpenVPN/Xray/Ikev2) can receive empty strings.

Feedback on the desired semantics (empty = keep server-advertised DNS / add no resolver at all / forbid when the server provides none) would be very welcome.

Notes

  • Verified statically; no build/test run (Qt toolchain is not available in my environment).
  • The field itself still rejects invalid input; only the "empty is an error" rule is removed.

🔄 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/3251 **Author:** [@ChesterFishmansWork](https://github.com/ChesterFishmansWork) **Created:** 10/2/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/3190-empty-primary-dns` --- ### 📝 Commits (5) - [`35185a0`](https://github.com/amnezia-vpn/amnezia-client/commit/35185a01b9d197fe3aa6c778c588dc53f260c4ea) fix(ui): allow saving an empty primary DNS - [`283ae07`](https://github.com/amnezia-vpn/amnezia-client/commit/283ae076964ca18988375fa05dcc4a51905fd809) fix(dns): keep an empty DNS setting out of the platform resolvers - [`f80269d`](https://github.com/amnezia-vpn/amnezia-client/commit/f80269dbcdf35559547c23462429b7167de87990) fix(dns): close review findings (OpenVPN/iptables/export/platform paths) - [`d4a90bb`](https://github.com/amnezia-vpn/amnezia-client/commit/d4a90bbfb8258bbb9a12a4a9ddc6878e120cf029) fix(dns): round-2 review follow-ups (ipsec script, root-script validation, platform symmetry) - [`80770fd`](https://github.com/amnezia-vpn/amnezia-client/commit/80770fd896a7f2efa3d5a86f4fcd9aec6f512357) fix(ui): allow saving an empty primary DNS ### 📊 Changes **27 files changed** (+435 additions, -95 deletions) <details> <summary>View changed files</summary> 📝 `client/android/protocolApi/src/main/kotlin/Protocol.kt` (+2 -1) 📝 `client/android/utils/src/main/kotlin/net/NetworkUtils.kt` (+25 -0) 📝 `client/android/wireguard/src/main/kotlin/org/amnezia/vpn/protocol/wireguard/Wireguard.kt` (+8 -6) 📝 `client/android/xray/src/main/kotlin/Xray.kt` (+3 -6) 📝 `client/core/configurators/configuratorBase.cpp` (+74 -3) 📝 `client/core/configurators/configuratorBase.h` (+10 -1) 📝 `client/core/configurators/openVpnConfigurator.cpp` (+17 -6) 📝 `client/core/configurators/wireguardConfigurator.cpp` (+4 -2) 📝 `client/core/controllers/selfhosted/installController.cpp` (+7 -1) 📝 `client/core/protocols/xrayProtocol.cpp` (+19 -6) 📝 `client/core/utils/constants/protocolConstants.h` (+4 -0) 📝 `client/core/utils/selfhosted/scriptsRegistry.cpp` (+15 -4) 📝 `client/daemon/daemon.cpp` (+30 -6) 📝 `client/daemon/interfaceconfig.cpp` (+13 -9) 📝 `client/mozilla/localsocketcontroller.cpp` (+10 -4) 📝 `client/platforms/ios/PacketTunnelProvider+WireGuard.swift` (+4 -0) 📝 `client/platforms/ios/PacketTunnelProvider+Xray.swift` (+17 -5) 📝 `client/platforms/ios/WGConfig.swift` (+19 -4) 📝 `client/platforms/ios/ios_controller.mm` (+32 -8) 📝 `client/platforms/linux/daemon/dnsutilslinux.cpp` (+10 -0) _...and 7 more files_ </details> ### 📄 Description ### Problem The Save handler in the DNS settings page refuses an empty `Primary DNS` field, so a configuration that must not push any DNS server through the tunnel (split tunneling only, or "keep whatever the server advertises") cannot be stored at all: ```qml if (primaryDns.textField.text === "") { primaryDns.errorText = qsTr("Primary DNS cannot be empty") return } ``` Fixes #3190. ### Change `client/ui/qml/Pages2/PageSettingsDns.qml` — drop the empty-value check in the Save handler. Input validation of the field itself (IP regexp) is untouched. ### ⚠️ Known gap / open question The UI part is small, but an independent review of the full data path found that **an empty `primaryDns` is not handled consistently downstream** — unlike `secondaryDns`, which is guarded in several places. If an empty primary DNS is the intended semantics, the following places should probably be fixed as well (happy to extend this PR or split them into a separate one once the expected behaviour is confirmed): - `client/core/protocols/xrayProtocol.cpp:37-42` — `m_dnsServers.push_back(QHostAddress(primaryDns))` is unconditional; an empty string becomes a null `QHostAddress` that is later passed to `iface->updateResolvers(tunName, m_dnsServers)`. - `client/daemon/daemon.cpp:172` — `resolvers.append(QHostAddress(config.m_primaryDnsServer))` is unconditional, while the secondary on the next line is guarded by `isEmpty()`. An empty primary therefore reaches `updateResolvers` and is written as an empty entry into systemd-resolved / macOS `ServerAddresses`. - `client/vpnConnection.cpp:135-145` — `routeAddList(..., QStringList() << dns1 << dns2)` for non-WireGuard containers (OpenVPN/Xray/Ikev2) can receive empty strings. Feedback on the desired semantics (empty = keep server-advertised DNS / add no resolver at all / forbid when the server provides none) would be very welcome. ### Notes - Verified statically; no build/test run (Qt toolchain is not available in my environment). - The field itself still rejects invalid input; only the "empty is an error" rule is removed. --- <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#3149
No description provided.