[PR #3426] feat(ui): show server ping, quality and live tunnel speed #3294

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

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amnezia-client/pull/3426
Author: @simsimian-dev
Created: 11/6/2026
Status: 🔄 Open

Base: dev ← Head: arena/a6b1ccdc-amnezia-client


📝 Commits (4)

  • ccf97e1 feat(ui): show server ping, quality and live tunnel speed
  • fbfaa2f fix(build): give the ping sender factory its platform define in test builds
  • 0dfa89d fix(build): compile the Windows ping sender as C++17
  • 77e9d2b fix(ping): stop reporting working servers as unreachable

📊 Changes

44 files changed (+1346 additions, -27 deletions)

View changed files

📝 client/amneziaApplication.cpp (+2 -0)
📝 client/android/src/org/amnezia/vpn/AmneziaVpnService.kt (+24 -16)
📝 client/android/utils/src/main/kotlin/net/TrafficStats.kt (+2 -0)
📝 client/cmake/sources.cmake (+25 -0)
📝 client/core/controllers/connectionController.cpp (+1 -0)
📝 client/core/controllers/connectionController.h (+1 -0)
📝 client/core/controllers/coreController.cpp (+6 -0)
📝 client/core/controllers/coreController.h (+4 -0)
📝 client/core/controllers/coreSignalHandlers.cpp (+15 -0)
📝 client/core/controllers/coreSignalHandlers.h (+1 -0)
➕ client/core/controllers/serverLatencyController.cpp (+128 -0)
➕ client/core/controllers/serverLatencyController.h (+47 -0)
📝 client/core/models/protocols/openVpnProtocolConfig.cpp (+35 -0)
📝 client/core/models/protocols/openVpnProtocolConfig.h (+3 -0)
📝 client/core/models/protocols/xrayProtocolConfig.cpp (+14 -0)
📝 client/core/models/protocols/xrayProtocolConfig.h (+1 -0)
📝 client/core/protocols/vpnProtocol.cpp (+37 -3)
📝 client/core/protocols/vpnProtocol.h (+8 -0)
📝 client/core/protocols/wireGuardProtocol.cpp (+1 -0)
📝 client/core/protocols/xrayProtocol.cpp (+1 -0)

...and 24 more files

📄 Description

Summary

Adds a ping tester and a live speed meter.

  • Server list: every server shows its latency (for example 48 ms) and a quality badge: Excellent, Good, Fair or Poor. A red Unreachable badge appears when a TCP-based server does not accept connections. A neutral No reply badge appears when a UDP server ignores every probe. All servers are tested when the list opens, and a refresh button sits next to the "Servers" header.
  • Home screen: ping and quality of the current server. While connected, it also shows the tunnel's live download and upload rate, updated every second.
    It only needs the host and port from each server's config: no SSH and no gateway calls. So it works for self-hosted servers, Amnezia Premium/Free and imported configs (WireGuard/AmneziaWG, OpenVPN, Xray VLESS/VMess/Trojan/Shadowsocks). Probes go straight from the device to the server's own endpoint, and no addresses are logged.

How it works

Latency: core/utils/latencyProbe sends 4 samples 200 ms apart, each with a 1.5 s timeout.

  • TCP-based configs (OpenVPN over TCP, Xray): measures the TCP handshake time to the server port.
  • UDP-based configs (WireGuard/AWG, OpenVPN over UDP): sends ICMP echo through the existing Mozilla PingSenders.
    • If ICMP gets no answer, it falls back to a TCP handshake to the VPN port. Amnezia's own setup_host_firewall.sh drops echo requests, so this is common.
    • In the fallback, a refusal (RST) counts as an answer, since it proves the host is up.
  • Handshake implementation: a native non-blocking connect() watched by a QSocketNotifier. QTcpSocket can't set socket options before it connects, and Windows needs SYN retransmissions turned off (SIO_TCP_INITIAL_RTO). Otherwise Windows retries a refused SYN for about a second, the answer misses the timeout, and a working server shows as unreachable.
  • Quality: under 80 ms is Excellent, under 150 Good, under 300 Fair, anything else Poor. The result drops one step on packet loss or jitter above 50 ms.
    Controllers and model:
  • core/controllers/serverLatencyController extracts each server's endpoint, runs the probes and keeps the results.
  • While connected, it re-tests only the current server, because other servers would be measured through the tunnel.
  • ServersModel gets latencyMs, latencyQuality and isLatencyTesting roles.
  • ServerLatencyUiController exposes the current server's result and the testing state to QML.
    Speed: computed once per second on the VPN thread from counters that already exist, so it adds no traffic.
  • OpenVPN: the management interface's bytecount.
  • WireGuard/AWG and Xray on Windows, Linux and macOS: byte counters of the tunnel interface (GetIfEntry2, sysfs, NET_RT_IFLIST2).
  • iOS and macOS Network Extension: WireGuard runtime stats; Xray uses hev_socks5_tunnel_stats.
  • Android: the service's STATISTICS_UPDATE events.
  • No counter available (for example IKEv2 on Windows): the speed row is hidden.
    Build changes:
  • cmake/sources.cmake: the client now builds mozilla/pingsender* and the platform ping senders.
  • windowspingsender.cpp: char8_t changed to uint8_t so it compiles in the C++17 client. Until now only the C++20 service built it.
  • tests/CMakeLists.txt: mozilla/pingsenderfactory.cpp gets its MZ_<PLATFORM> define in test builds, because it fails with #error without one.

Testing

  • Fork CI (GitHub Actions): the Linux and Windows (MSVC) builds pass on the last commit, including the tests and the installers (run, cancelled after those jobs finished because the Android jobs wait for a runner the fork doesn't have). No new compiler warnings.
  • Not built in CI: the fork has no signing certificates, so the macOS and iOS jobs stop at signing setup. Android has no runner on the fork. None of the three platforms has been built.
  • Windows, release build from this branch: the speed meter works on a real connection. The fix in the last commit, for working servers shown as unreachable, has not been confirmed on Windows yet.
  • Local (Linux): probe and controller tests against a TUN responder that simulates servers with fixed ICMP/TCP delays, RSTs and drops.
    • Measured values match for self-hosted AWG, OpenVPN over TCP, imported WireGuard/.ovpn/Trojan/VLESS/Shadowsocks, and Premium AWG with ICMP blocked.
    • Servers that drop everything report No reply (UDP) or Unreachable (TCP).
    • Traffic counters were checked against sysfs on a TUN interface.
    • QML was rendered offscreen with mocked controllers, with no QML warnings.
  • Compiled locally with clang, not run: latencyProbe.cpp for a Windows target, and the macOS counter code against Darwin headers (x86_64 and arm64).
  • Not compiled or run: the Swift, Objective-C++ and Kotlin changes for iOS/macOS Network Extension and Android.
    New strings use qsTr(). Translation files are not updated.

🔄 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/3426 **Author:** [@simsimian-dev](https://github.com/simsimian-dev) **Created:** 11/6/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `arena/a6b1ccdc-amnezia-client` --- ### 📝 Commits (4) - [`ccf97e1`](https://github.com/amnezia-vpn/amnezia-client/commit/ccf97e1b870fb8e39d2581040078a49d96323fb9) feat(ui): show server ping, quality and live tunnel speed - [`fbfaa2f`](https://github.com/amnezia-vpn/amnezia-client/commit/fbfaa2f481229a60a4b87ea9911fa4a973e6fded) fix(build): give the ping sender factory its platform define in test builds - [`0dfa89d`](https://github.com/amnezia-vpn/amnezia-client/commit/0dfa89df9312f2f1c5d91268844fc51ea7e76333) fix(build): compile the Windows ping sender as C++17 - [`77e9d2b`](https://github.com/amnezia-vpn/amnezia-client/commit/77e9d2b86eeab0b4f3f515e9987ba457754537b1) fix(ping): stop reporting working servers as unreachable ### 📊 Changes **44 files changed** (+1346 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `client/amneziaApplication.cpp` (+2 -0) 📝 `client/android/src/org/amnezia/vpn/AmneziaVpnService.kt` (+24 -16) 📝 `client/android/utils/src/main/kotlin/net/TrafficStats.kt` (+2 -0) 📝 `client/cmake/sources.cmake` (+25 -0) 📝 `client/core/controllers/connectionController.cpp` (+1 -0) 📝 `client/core/controllers/connectionController.h` (+1 -0) 📝 `client/core/controllers/coreController.cpp` (+6 -0) 📝 `client/core/controllers/coreController.h` (+4 -0) 📝 `client/core/controllers/coreSignalHandlers.cpp` (+15 -0) 📝 `client/core/controllers/coreSignalHandlers.h` (+1 -0) ➕ `client/core/controllers/serverLatencyController.cpp` (+128 -0) ➕ `client/core/controllers/serverLatencyController.h` (+47 -0) 📝 `client/core/models/protocols/openVpnProtocolConfig.cpp` (+35 -0) 📝 `client/core/models/protocols/openVpnProtocolConfig.h` (+3 -0) 📝 `client/core/models/protocols/xrayProtocolConfig.cpp` (+14 -0) 📝 `client/core/models/protocols/xrayProtocolConfig.h` (+1 -0) 📝 `client/core/protocols/vpnProtocol.cpp` (+37 -3) 📝 `client/core/protocols/vpnProtocol.h` (+8 -0) 📝 `client/core/protocols/wireGuardProtocol.cpp` (+1 -0) 📝 `client/core/protocols/xrayProtocol.cpp` (+1 -0) _...and 24 more files_ </details> ### 📄 Description ## Summary Adds a ping tester and a live speed meter. - **Server list:** every server shows its latency (for example `48 ms`) and a quality badge: Excellent, Good, Fair or Poor. A red **Unreachable** badge appears when a TCP-based server does not accept connections. A neutral **No reply** badge appears when a UDP server ignores every probe. All servers are tested when the list opens, and a refresh button sits next to the "Servers" header. - **Home screen:** ping and quality of the current server. While connected, it also shows the tunnel's live download and upload rate, updated every second. It only needs the host and port from each server's config: no SSH and no gateway calls. So it works for self-hosted servers, Amnezia Premium/Free and imported configs (WireGuard/AmneziaWG, OpenVPN, Xray VLESS/VMess/Trojan/Shadowsocks). Probes go straight from the device to the server's own endpoint, and no addresses are logged. ## How it works **Latency:** `core/utils/latencyProbe` sends 4 samples 200 ms apart, each with a 1.5 s timeout. - **TCP-based configs** (OpenVPN over TCP, Xray): measures the TCP handshake time to the server port. - **UDP-based configs** (WireGuard/AWG, OpenVPN over UDP): sends ICMP echo through the existing Mozilla `PingSender`s. - If ICMP gets no answer, it falls back to a TCP handshake to the VPN port. Amnezia's own `setup_host_firewall.sh` drops echo requests, so this is common. - In the fallback, a refusal (RST) counts as an answer, since it proves the host is up. - **Handshake implementation:** a native non-blocking `connect()` watched by a `QSocketNotifier`. `QTcpSocket` can't set socket options before it connects, and Windows needs SYN retransmissions turned off (`SIO_TCP_INITIAL_RTO`). Otherwise Windows retries a refused SYN for about a second, the answer misses the timeout, and a working server shows as unreachable. - **Quality:** under 80 ms is Excellent, under 150 Good, under 300 Fair, anything else Poor. The result drops one step on packet loss or jitter above 50 ms. **Controllers and model:** - `core/controllers/serverLatencyController` extracts each server's endpoint, runs the probes and keeps the results. - While connected, it re-tests only the current server, because other servers would be measured through the tunnel. - `ServersModel` gets `latencyMs`, `latencyQuality` and `isLatencyTesting` roles. - `ServerLatencyUiController` exposes the current server's result and the testing state to QML. **Speed:** computed once per second on the VPN thread from counters that already exist, so it adds no traffic. - **OpenVPN:** the management interface's `bytecount`. - **WireGuard/AWG and Xray on Windows, Linux and macOS:** byte counters of the tunnel interface (`GetIfEntry2`, sysfs, `NET_RT_IFLIST2`). - **iOS and macOS Network Extension:** WireGuard runtime stats; Xray uses `hev_socks5_tunnel_stats`. - **Android:** the service's `STATISTICS_UPDATE` events. - **No counter available** (for example IKEv2 on Windows): the speed row is hidden. **Build changes:** - `cmake/sources.cmake`: the client now builds `mozilla/pingsender*` and the platform ping senders. - `windowspingsender.cpp`: `char8_t` changed to `uint8_t` so it compiles in the C++17 client. Until now only the C++20 service built it. - `tests/CMakeLists.txt`: `mozilla/pingsenderfactory.cpp` gets its `MZ_<PLATFORM>` define in test builds, because it fails with `#error` without one. ## Testing - **Fork CI (GitHub Actions):** the Linux and Windows (MSVC) builds pass on the last commit, including the tests and the installers ([run](https://github.com/simsimian-dev/amnezia-client/actions/runs/42238054548), cancelled after those jobs finished because the Android jobs wait for a runner the fork doesn't have). No new compiler warnings. - **Not built in CI:** the fork has no signing certificates, so the macOS and iOS jobs stop at signing setup. Android has no runner on the fork. **None of the three platforms has been built.** - **Windows, release build from this branch:** the speed meter works on a real connection. The fix in the last commit, for working servers shown as unreachable, has not been confirmed on Windows yet. - **Local (Linux):** probe and controller tests against a TUN responder that simulates servers with fixed ICMP/TCP delays, RSTs and drops. - Measured values match for self-hosted AWG, OpenVPN over TCP, imported WireGuard/.ovpn/Trojan/VLESS/Shadowsocks, and Premium AWG with ICMP blocked. - Servers that drop everything report No reply (UDP) or Unreachable (TCP). - Traffic counters were checked against sysfs on a TUN interface. - QML was rendered offscreen with mocked controllers, with no QML warnings. - **Compiled locally with clang, not run:** `latencyProbe.cpp` for a Windows target, and the macOS counter code against Darwin headers (x86_64 and arm64). - **Not compiled or run:** the Swift, Objective-C++ and Kotlin changes for iOS/macOS Network Extension and Android. New strings use `qsTr()`. Translation files are not updated. --- <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#3294
No description provided.