[PR #3405] fix(settings): restore split tunneling route modes saved as strings #3284

Open
opened 2026-11-07 17:58:57 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amnezia-client/pull/3405
Author: @OverFitted
Created: 11/5/2026
Status: 🔄 Open

Base: dev ← Head: fix/restore-split-tunneling-route-mode


📝 Commits (1)

  • 63c95d2 fix(settings): restore split tunneling route modes saved as strings

📊 Changes

2 files changed (+15 additions, -2 deletions)

View changed files

📝 client/core/controllers/settingsController.cpp (+2 -2)
📝 client/tests/testBackupExportImport.cpp (+13 -0)

📄 Description

Summary

Keep the site and app split tunneling route modes when restoring a backup that was created on Linux or Android.

Problem

On Linux and Android QSettings uses the INI format, which does not keep value types, so SecureQSettings::backupAppConfig() writes Conf/routeMode and Conf/appsRouteMode as JSON strings (for example "2"). SettingsController::restoreAppConfigFromData() reads them with QJsonValue::toInt(), which returns 0 for a string, so the restore always emits RouteMode::VpnAllSites and AppsRouteMode::VpnAllApps.

With site split tunneling enabled, VpnAllSites is a mode the rest of the app does not expect:

  • OpenVpnConfigurator::processConfigWithLocalSettings() removes redirect-gateway and has no branch for it, and VpnConnection::onConnectionStateChanged() deletes the 0.0.0.0 route without adding any other, so a self-hosted OpenVPN connection reports Connected while traffic does not go through the tunnel.
  • After the next start IpSplitTunnelingController migrates VpnAllSites to VpnOnlyForwardSites, so a user who had All sites except ends up with the opposite mode.
  • On Android the app route mode becomes VpnAllApps, which reads the empty AllApps list, so the restored app list is not applied.

The boolean flags next to these values are already read through toVariant() for the same reason.

Changes

  • Read Conf/routeMode and Conf/appsRouteMode through toVariant().toInt(), which handles both numbers and numeric strings.
  • Add testRestoreRouteModeStoredAsString to BackupExportImportTest.

Backward compatibility

Backups that store the modes as numbers (Windows, macOS) are read exactly as before.

Verification

  • Built the Windows x64 client, service and tests in Release mode (MSVC 19.35, Qt 6.10.1) against dev at ac175c8.
  • The new test fails on dev without the fix and passes with it.
  • ctest: all tests pass.

🔄 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/3405 **Author:** [@OverFitted](https://github.com/OverFitted) **Created:** 11/5/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/restore-split-tunneling-route-mode` --- ### 📝 Commits (1) - [`63c95d2`](https://github.com/amnezia-vpn/amnezia-client/commit/63c95d29ed077142ff558181e0120a4c6bf41b75) fix(settings): restore split tunneling route modes saved as strings ### 📊 Changes **2 files changed** (+15 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `client/core/controllers/settingsController.cpp` (+2 -2) 📝 `client/tests/testBackupExportImport.cpp` (+13 -0) </details> ### 📄 Description ## Summary Keep the site and app split tunneling route modes when restoring a backup that was created on Linux or Android. ## Problem On Linux and Android `QSettings` uses the INI format, which does not keep value types, so `SecureQSettings::backupAppConfig()` writes `Conf/routeMode` and `Conf/appsRouteMode` as JSON strings (for example `"2"`). `SettingsController::restoreAppConfigFromData()` reads them with `QJsonValue::toInt()`, which returns `0` for a string, so the restore always emits `RouteMode::VpnAllSites` and `AppsRouteMode::VpnAllApps`. With site split tunneling enabled, `VpnAllSites` is a mode the rest of the app does not expect: - `OpenVpnConfigurator::processConfigWithLocalSettings()` removes `redirect-gateway` and has no branch for it, and `VpnConnection::onConnectionStateChanged()` deletes the `0.0.0.0` route without adding any other, so a self-hosted OpenVPN connection reports *Connected* while traffic does not go through the tunnel. - After the next start `IpSplitTunnelingController` migrates `VpnAllSites` to `VpnOnlyForwardSites`, so a user who had *All sites except* ends up with the opposite mode. - On Android the app route mode becomes `VpnAllApps`, which reads the empty `AllApps` list, so the restored app list is not applied. The boolean flags next to these values are already read through `toVariant()` for the same reason. ## Changes - Read `Conf/routeMode` and `Conf/appsRouteMode` through `toVariant().toInt()`, which handles both numbers and numeric strings. - Add `testRestoreRouteModeStoredAsString` to `BackupExportImportTest`. ## Backward compatibility Backups that store the modes as numbers (Windows, macOS) are read exactly as before. ## Verification - Built the Windows x64 client, service and tests in Release mode (MSVC 19.35, Qt 6.10.1) against `dev` at ac175c8. - The new test fails on `dev` without the fix and passes with it. - `ctest`: all tests pass. --- <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#3284
No description provided.