mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-12-03 18:04:18 +07:00
Open
opened 2026-11-07 17:59:01 +07:00 by bsakaguchi
·
0 comments
No Branch/Tag specified
dev
feat/pages-ui-tests
feat/otp-free-users-login
fix/refresh-external-ip-and-proxy-config-in-start-sh
fix/ios-keep-nav-bar-below-status-bar-and-lift-rename-sheet-over-keyboard
fix/ios-stop-hev-before-restarting-xray-tunnel
feat/whatsapp-proxy
fix/keep-socks-and-pfx-secrets-out-of-command-lines
fix/pass-the-tunnel-config-over-a-named-pipe
feat/test-xray-pages-ui
fix/expect-server-xray-v26.10.31
fix/align-xray-settings-with-core-defaults-and-add-contract-tests
feat/xtun
feat/separated-ui-models-and-controllers-tests
fix/keep-default-godebug-when-disabling-async-preemption
feat/otp-login
feat/android-tests
fix/server-removal-navigation-and-sheet-reopen
feat/add-deep-link
feat_copy_docker_configs
fix/gateway-requests-on-slow-or-blocked-dns
fix/bypass-proxy
feat/api-tests
fix/serialize-log-record-writes-and-pin-log-date-format-locale
fix/libagw-review-fixes
fix/ios-xray-ipv6-leak
fix/macos-xray-ipv6-leak
feat/add-support-include-split-tunnel
fix/win-xray-app-split-tunneling
fix/bug-when-saving-after-canceling
fix/xray-reconnect-crash
fix/share-empty-config-on-ssh-timeout
fix/ssh-credentials-input
fix/updater-verify-signature
fix/async-ssh-threading
fix/xray-check-inet-and-liveness-monitor
fix/selfhosted-server-installations
feat/add-support-ikev2-macos
fix/icons-different-color-themes
feat/add_support_arm_windows
feat/fixed-push-notifications-on-VPN-connect-disconnect-2
feat/implement-QR-code-generation-and-scanning
feat/file-password-protection
feat/add-support-split-tunnel-macos
feat/tests
fix/android-register-unacknowledged-purchase
fix/share_on_linux
mirroring-to-outside
feat/self-diagnostics-log
feat/amnezia-free-vless-switch
fix/conan_build_android_on_win
fix/linux-reconnect-dns-reliability
fix/windows-connection-stability
fix/linux-reconnect-refactoring
fix/ios-groupidentifier-order
feat/xray-subscription-link
fix/minor-fixes
fix/xray-config-inplace-edit
feat/amnezia-sdk-typed-api
feat/amnezia-sdk-integration
feat/force-update-native
refactor/marketplace-update-popup
feat/force-update
fix/valnurability_dev
chore-xcode-version
fix/empty-i1-i5
build_qt_6_10_1
master
feat/protocol-selection
fix/openvpn_install
feat/locations_change
feat/locations_change_rework
feature/local-proxy-integration
fix/filepicker_atv
fix_valnurability
fix/macos-ne-codesign-4.8.19.0
temp-branch-for-testing
fix/rebased_4_8_19_linux_fix_error
feat/proxy-storage-cache
fix/zeroed-params
fix/killswitch-blocknets-linux
update/translation_RU
fix/self_hosted_reinstall_error
feat/selfhosted-dns
fix/agp_version_up
feat/switch_to_alive_protocol
feat/support_multipeer
server_scripts_update
fix/extended-vless-configuration
chore/apple-ci-cd-macos-versions
feat/add-telemt
fix/android_keystore_read_error
feat/add-mtproxy
chore/bump-qt-version
fix/make_dbus_async
feature/dns
rebase/apple-tv-target-on-conan
fix/outbound_freedom_xray_with_dns_fix
feat/apk_support
feat/fallback-proxy
feat/apple-tv-target
fix/dns_reconnection_issue
feat/fixed-push-notifications-on-VPN-connect-disconnect
fix/linux-firewall
docker-regional-locks
appstore-review-popup
feat/storekit2
fix/uninstall-split-tunnelling-driver
revert-2376-chore/license-file
support_16kb_android
bump_version
feat_add_review_android
bugfix/translation-absence-on-subscription-key-page
feat/location-separation-by-region
bugfix/text-moving-when-resing-window
fix_backup
feature/add-purchase-android
bugfix/moved-text-while-resizing-window
bugfix/incorrect-killswitch-restore-from-backup
fix/backup-exclude-secondary-api-configs
feat/proxy-fields-for-dev-console
bugfix/ovpn-ios-fix
bugfix/linux-bundle-libraries
fix/xray-app-split-win
fix/upload-to-s3
chore/add-release-date-upload
feat_add_webview_support
feature/configuration-transfer-through-qr
feat/bot-key-unlink-device
fix/ad-link-lang-support
fix/qsecuresettings-with-android
feat/add-support-arm64-win
spanish-translations
fix/context-menu
feat/add-system-dns-support
fix/qt6-9-support
fix/qt6_9_support
bugfix/strict-killswitch-ui
android-7
chore/minor-bugfixes
feature/awg-net-fix-macos-wakeup
fixbug/ios18
bugfix/ios-ne-crash
fix/linux-tray-quit-button
cryptpad-support
bugfix/disable-linux-killswitch
fix/minor-ui-fixes
feature/setup-guid-tun2socks
feature/linux-ipsec
feature/ipsec-linux
refactoring/server-config-in-classes
feature/macos-ipsec
fix/ui-fixes-after-merge-with-d20ed4a
chore/focus_control_after_qt_6.9_migration
feature/integrate-xray-as-a-library
maxos-awg-fix
feature/add-new-awg-docker-image
chore/update-3rd-prebuild
feature/test-news
fix/api-conf-files
bugfix/split-tunneling-with-api-config
bugfix/ios-awg-new-fields
feature/special-handshake-2
feat/xray-api-support
fix/desktop-entry
bugfix/shadowsocks-cipher-setting-not-changing
feature/update-tap
bugfix/openvpn_import_fix
feature/ability-to-change-port-after-installing-xray
bugfix/strict-mode-ovpn
bugfix/win-ipv6-ovpn
bugfix/subnet-adress-setting
exception-podman-docker
bugfix/fix-listviewtype-scrolling
bugfix/win-disabled-ipv6
bugfix/win-ipv6-disabled-ovpn
feature/killswitch-strict-mode
feature/awg-network-check
feature/empty-split-tunneling-list
feature/support-info
chore/update-go-version
checking-Linux-version
update_server_scripts
bugfix/button-selection-easy-setup-page
feature/old-api-proxy
patch/user-checking
fix/correcting-version
support-podman
support_podman
user-checking-patch
feature/check-docker-version
feature/allowed-dns-list
without_lsof
chore/error-body
Update-amneziavpn_ru_RU
shiroow-patch-8
shiroow-patch-7
shiroow-patch-6
shiroow-patch-5
shiroow-patch-4
shiroow-patch-3
shiroow-patch-2
shiroow-patch-1
check_sudo_permissions
feature/euphoria
add_next_octet_to_ip_settings
bugfix/mobile-controllers-init
euphoria
bugfix/android-crush
feature/macox-network-extension
bugfix/pre-release-hotfixes
bugfix/ipsec-pfs
chore/ios-site-links
checking_sudo_permissions
feature/android-tv
improve_navigation_cpp
bugfix/linux-firewall-install
fixbug/wireguard-handshake-time
ReadmeRu_full
feature/xray-user-management
feature/subscription-end-date
chore/clang-format
feature/ru-in-readme
chore/increased-api-timeout
chore/deploy-workflow
bugfix/services-list-scroll
wheel_group_suppor
chore/bump-xcode-version
fixbug/mac-network-extension
feature/android-gpb
feature/page-home-drawer-country-selection
checking-sudo-users
bugfix/service-info-from-response
fixbug/build-macos-ne-2
android-qt-6.7.3
fixbug/build-macos-ne
bugfix/wg-windows-log-folder
feature/psk-key-api-request
bugfix/user-management-qml-warnings
fix/macos-network-extension
fixbug/macos-NE-build
bugfix/fixed-isDevEnv-initialization
bugfix/revert-ios-ovpn
feature/tun2socksSrv
fix/disable_singleapp
feature/awg-wg-name-resolving
feature/disable-dhcp
bugfix/allowed-ips-old-configs
feature/goodbyedpi
feature/add-exception-log
refactoring/remove-ipv6-from-default-routes
refactoring/singleapplication-submodule
macos-dirty-build
test/gateway
Update-amneziavpn_fa_IR.ts
bugfix/ipsec-win
fix/xray-custom-port
improve-tab-navigation
test-win-11
feature/android-tv-remote-control-support
KsZnak-patch-1
feature/awg-wg-qr
bugfix/fix-loopback-splittunel
fix/setup_host_firewall
feature/android-xray
feature/openvpn-pass
feature/connection-string
fix/clickable-errors
bugfix/api_1100_fix
feature/graphview
testsvg
feature/update-win-awg
feature/open-as-amnezia
feature/update-mozilla-upstream
bugfix/qr-code-cutting
feature/native-wg-psk
test/awg-centos
bugfix/hide_error
feature/add-uninstaller-checkbox
bugfix/cancel-button-on-install-page
bugfix/anchors-page-home-warning
awg-udptlspipe
button-focus-fix
revert-677-fix/logger
bugfix/Revert_PR_596
bugfix/allowed-ips-api-configs
bugfix/on-escape-pressed
feature/auto-scroll-for-server-selection-list
fix/ui-fixes
translations/update_fa_IR.ts
feature/new-awg-docker-container
bugfix/awg_ipv6_fix
feature/tab-navigation
fix/username-no-autocapitalization
sure
refactoring/servers-model-cleanup
feature/wg-mtu-setup-ios
3rd_adaptation_to_diff_OS
sudo_not_found
test/docker-ce
bugfix/double_clear_server_from_amnezia
fix/android
client/3rd-prebuilt
revert-559-KsZnak-translation-ru-ex
KsZnak-translation-ru-ex
KsZnak-br1
KsZnak-text-change
feature/api-awg
feature/error-code-output
feature/win_x32_builds
text/debug-output
feature/ovpn3-desktop-cli
bugfix/secureqsettings-deadlock
refactoring/change-settings-when-connected
files_check
ArchLinux-support
second_adaptation_to_diff_os
sudo
refactoring/android-build
adaptation_to_different_os
feature/online_installer_for_v4
update_to_r2
bugfix/return-after-installation
feature/custom_drawer_component
bugfix/split-tunneling
bugfix/existing-awg-container
revert-370-feature/custom_drawer_component
bugfix/adapted_awg_questiondrawer
bugfix/updated_drawer_height_pageserverdata
bugfix/translated_new_source_strings_to_chinese
feature/split-tunneling-config
feature/accessibility-support
branch_connectivity_change_fix
feature/ikev2_android
android_ss_transport
bugfix/macos_fixes
feature/nextcloud-support
feature/macos_network_extension
android_pt_transport_source
feature/ios-openvpn3-pluggable-transport-Cloak
bugfix/cloak_for_desktops_fix
arm-build-macos
fix-macos-build-brew
bugfix/ios-build-openvpnadapter-from-source
feature/download-native-wireguard-config-on-connect
feature/v2ray-container
bugfix/dpkg-busy-checking-stuck
feature/online-installer
dev-killswitch
dev-netadapters
5.1.0.6
5.0.4.2
5.0.4.1
5.0.4.0
5.0.3.0
5.0.2.1
5.0.2.0
5.0.1.5
5.0.0.5
5.0.0.2
4.8.21.0
4.8.19.0
4.8.18.0
4.8.17.0
4.8.16.0
4.8.15.4
4.8.15.0
4.8.14.5
4.8.14.1
4.8.12.9
4.8.12.8
4.8.12.7
4.8.12.6
4.8.11.4
4.8.11.3
4.8.11.2
4.8.11.1
4.8.11.0
4.8.10.0
4.8.9.2
4.8.9.1
4.8.9.0
4.8.8.3
4.8.8.2
4.8.8.1
4.8.7.2
4.8.7.1
4.8.7.0
4.8.6.0
4.8.5.0
4.8.4.5
4.8.4.4
4.8.4.3
4.8.4.2
4.8.4.1
4.8.4.0
4.8.3.2
4.8.3.1
4.8.2.3
4.8.1.9
4.8.1.0
4.8.0.5
4.7.0.0
4.6.0.3
4.6.0.1
4.5.3.0
4.5.0.0
4.4.0.0
4.3.0.0
4.2.1.0
4.2.0.1
4.1.2.0_cloak_pt_experimental
4.1.0.1
4.0.8
3.1.0
3.0.8
3.0.7
3.0.5
2.1.2
2.1.0
2.0.10
2.0.9
2.0.8
2.0.7
2.0.6
2.0.5
2.0.1
2.0
1.9.1
1.9
1.8
1.7
1.6
1.5
1.4
1.3
1.2
1.1
1.0
No labels
pull-request
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
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#3292
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/amnezia-vpn/amnezia-client/pull/3425
Author: @OstarkovSN
Created: 11/6/2026
Status: 🔄 Open
Base:
dev← Head:route-batch-dev📝 Commits (1)
ad35f50windows: add split tunnelling exclusion routes in one batch📊 Changes
7 files changed (+158 additions, -60 deletions)
View changed files
📝
client/daemon/daemon.cpp(+23 -14)📝
client/daemon/daemon.h(+1 -1)📝
client/daemon/wireguardutils.h(+14 -0)📝
client/platforms/windows/daemon/windowsroutemonitor.cpp(+104 -39)📝
client/platforms/windows/daemon/windowsroutemonitor.h(+6 -2)📝
client/platforms/windows/daemon/wireguardutilswindows.cpp(+8 -4)📝
client/platforms/windows/daemon/wireguardutilswindows.h(+2 -0)📄 Description
Problem
On Windows, "all sites except" split tunnelling with a large site list makes
activation take minutes. The daemon installs one exclusion route per listed
prefix, and each one re-reads the whole, growing, routing table. With about
8,700 prefixes, 5.1.0.6 took almost 5 minutes from
activatetoConnection status: 1.This PR fixes that slow route install, and only that. A separate issue
remains after activation: the GUI can stay on "Connecting..." for minutes
more, because the daemon's 250 ms
checkHandshake()timer is starved whilerouteChanged()rescans run on the same thread. This PR does not changethat path; see Known limitations.
Observed symptom
with a Russian-IP bypass list: about 8,700 IPv4 prefixes (8,675 exclusion
route add attempts in the run below).
Command received: activateand
Connection status: 1, with 30,428WindowsRouteMonitorlines inbetween, almost all of them from adding exclusion routes one by one.
(
netsh -f, 500 commands per batch) is fast. That timing is not includedhere. It suggests, but does not prove, that creating the routes is not the
bottleneck. The counts below locate the cost.
Root cause
In this mode every listed site becomes an entry in
excludedAddresses, andDaemon::activate()(andDaemon::switchServer()) calladdExclusionRoute()once per address. On Windows,WindowsRouteMonitor::addExclusionRoute()does the following for everyprefix:
GetIpForwardTable2(): copies the whole routing table out of the kernel.The table grows by one row for each exclusion route already added.
updateInterfaceMetrics(): callsGetIpInterfaceTable()and writes onedebug line per connected interface.
updateCapturedRoutes(family, table): when default route capture is on,this calls
isRouteExcluded(), which is linear in the number ofexclusions, for every eligible system route.
updateExclusionRoute(): a linear scan of the table.Every log line is flushed to the log file. For N prefixes the cost is O(N²)
table rows copied out of the kernel and scanned. During
switchServer(),where capture is already enabled, it adds O(T·N²) in
isRouteExcluded(),where T is the number of system routes. For N = 8,664 that is about
37 million rows copied (see the measurements below).
Fix
WindowsRouteMonitor::addExclusionRoutes(const QList<IPAddress>&). Foreach address family it fetches the routing table and interface metrics
once, then builds each exclusion row, computes its next hop against that
snapshot with the existing
updateExclusionRoute(), installs it, andrecords it in
m_exclusionRoutes.updateCapturedRoutes()runs once atthe end. A single summary line (
Added X of N exclusion routes (I installed, F failed) in T ms) replaces the per-prefix debug lines.Interface, capture, warning and error lines are logged as before, but
updateInterfaceMetrics()now runs once per family.addExclusionRoute()keeps its signature, its log line and its returnvalue, and now calls the batch with one prefix. The row initialisation
moved verbatim into
initExclusionRow().updateExclusionRoute()now returnsfalsewhenCreateIpForwardEntry2()fails. It still logs the error as before. The batch uses the value only
for the summary count, and
routeChanged()ignores it.WireguardUtilsgets a virtualaddExclusionRoutes()whose default addsthe routes one by one, so Linux and macOS routing code is unchanged.
Windows overrides it, and
excludeLocalNetworks()uses it too. Thedaemon-level duplicate handling below applies to every platform.
Daemon::addExclusionRoute()is replaced byDaemon::addExclusionRoutes().It applies the same
m_excludedAddrSetreference counting, but collectsthe not-yet-excluded prefixes and adds them in one call. One difference:
if a prefix appears twice in the list and the first attempt fails, the
old loop tried again on the second occurrence. The new code does not.
updateInterfaceMetrics()now returns whether it read the interfacetable. The batch keeps calling it for each prefix until it succeeds,
which matches the old per-prefix retry.
Why the result is the same
updateExclusionRoute()skips every route with the same protocol and metricas the row being placed:
MIB_IPPROTO_NETMGMTwithEXCLUSION_ROUTE_METRIC,which are the exclusion routes this monitor creates. It also skips routes on
the VPN interface, which is where captured routes go. So the rows created
earlier in a batch can never change the next hop chosen for a later prefix,
and, as long as the system routes and interface metrics stay the same, one
snapshot gives the same answer as re-reading the table every time.
If another program changes the IPv4 routing table during the batch, the
existing
NotifyRouteChange2()→routeChanged()path re-evaluates everyentry of
m_exclusionRoutesafterwards, and the batched rows are in it, asbefore. IPv6 has no such notification (see Known limitations). An IPv6
gateway change during the batch is therefore not picked up by the remaining
IPv6 prefixes of that batch, which the per-prefix loop could have seen. The
batch now runs for milliseconds to seconds instead of minutes.
A transient
GetIpForwardTable2()failure fails only the prefix that hitit. The next prefix tries the fetch again, as the per-prefix code did.
Intentional behaviour change
updateCapturedRoutes()used to run before each new prefix was recorded asexcluded. So a route covered by the most recently added exclusion could stay
cloned into the tunnel until the next route change notification. Example:
excluding
192.168.1.0/24while default route capture is on left192.168.1.0/24 → tunnelin place. Captured routes are now updated afterthe new prefixes are recorded, so this window is gone.
Complexity
N = number of exclusion prefixes, T₀ = size of the system routing table
before connecting (typically tens of rows). Normal case: all fetches
succeed, and capture is not counted.
GetIpForwardTable2callsGetIpInterfaceTablecallsisRouteExcludedwork (capture on)CreateIpForwardEntry2callsTesting
Host-side equivalence harness. The original and patched
windowsroutemonitor.cppwere compiled on Linux (Qt 6.8, g++) against astub IP Helper API backed by an in-memory routing table. Both were driven
through the same scenarios, and the route rows were compared field by
field (destination, interface, next hop, metric, protocol):
existing routes, longest-prefix and metric ties, loopback/multicast,
bare addresses, IPv6, a duplicate inside the batch);
routeChanged(), which re-points7,254 exclusion rows;
addExclusionRoute(), thenflushExclusionRoutes();switchServer()case);GetIpForwardTable2()call failing (that prefix fails, andthe later ones recover);
GetIpInterfaceTable()calls failing on a freshmonitor.
The initial install was compared at N = 8,664, 1,500 and 11. The capture
and failure scenarios use smaller lists, from 11 to 400 prefixes. Results
are identical in every scenario except the capture-ordering correction
described above. A deliberate mutation that stops retrying a failed
interface table read is detected. Two earlier mutations were also
detected (not recording batched rows, and skipping the interface metric
refresh), but those mutant builds were not kept. The harness does not model notification delivery or the
daemon lifecycle; those paths are unchanged apart from the daemon
duplicate case described above.
Counted with N = 8,664 and a 12-row system table:
GetIpForwardTable2callsGetIpInterfaceTablecallsCreateIpForwardEntry2callsWindows build. Built with the project's
Build-WindowsCI job(MSVC 2022, Qt 6.10.1) to an
.msi: https://github.com/autumnfleet/amnezia-client/actions/runs/42018968655(fork CI with only this job enabled; the summary log string is present in
the built
AmneziaVPN-service.exe)Real-world test. Windows 10 22H2 (x64), AmneziaWG, "all sites except"
with the same Russian-IP list, using the MSI from the CI run above (the app reports
commit
89618b6, which is this commit plus a fork-only CI workflow change).It is compared against stock 5.1.0.6 on the same machine, using one
completed run per build. The runs were on different days, on different
local networks and in a different boot state: the patched activation began
about 2.5 minutes after boot. So the totals are indicative only. Times are from the service log (UTC).
Command received: activate→Connection status: 1Adding exclusion route forlinesAdded 8673 of 8673 exclusion routes ( 8673 installed, 0 failed) in 418 ms, plus 2 single addsWindowsRouteMonitorlines in that windowCreating Wintun interface→Using Wintun/0.14)Most of the patched run's 24.6 s was Wintun adapter creation: a device
query timed out and WireGuard retried "because system just booted". That
is unrelated to this change. The installed routes were not inspected with
route print. The only evidence that they are correct on Windows is thatthe batch reported 8,673 installed and 0 failed, plus the host-side
equivalence harness above. The two single adds after the batch logged the
same
Exclusion route already existswarning andFailed to update route: 87error in both builds.Not run:
ctest, and builds or runs on Linux and macOS. On thoseplatforms the daemon change goes through the default
WireguardUtils::addExclusionRoutes(), which adds the routes one by one.Known limitations not changed by this PR
NotifyRouteChange2()is registered forAF_INETonly, so IPv6 routechanges never trigger
routeChanged(). This predates the PR. Its only newinteraction is the snapshot window described above.
routeChanged()re-evaluates every exclusion against the full table oneach notification, which is O(N·T) per notification. These rescans are
still expensive with large lists, and they can delay the "connected"
notification (next item).
The daemon reports "connected" only from
checkHandshake(), driven by a250 ms timer. After activation,
routeChanged()rescans on the samethread appear to starve that timer. In the patched run above, the handshake had
completed before
Connection status: 1, but the firstChecking for handshake...came 4 min 36 s later, and only then did the GUIshow "connected". In the 5.1.0.6 run no handshake check appeared in the
36.5 minutes of log after
Connection status: 1. This PR does not touch that path. It is diagnosed in #2516 and#3114, which also include their own route batching, so maintainers may
prefer to take batching from one of those. This PR is the smaller change,
limited to the route install path.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.