[PR #90] backend: track connection status per tunnel and detect reconnects #95

Open
opened 2026-10-13 21:06:03 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amneziawg-android/pull/90
Author: @erophey7
Created: 8/8/2026
Status: 🔄 Open

Base: master ← Head: fix/multi-tunnel-status


📝 Commits (1)

  • 104b3de backend: track connection status per tunnel and detect reconnects

📊 Changes

4 files changed (+62 additions, -45 deletions)

View changed files

📝 tunnel/src/main/java/org/amnezia/awg/backend/AwgQuickBackend.java (+47 -32)
📝 tunnel/src/main/java/org/amnezia/awg/backend/GoBackend.java (+1 -1)
📝 tunnel/src/main/java/org/amnezia/awg/backend/StatusCallback.java (+4 -2)
📝 ui/src/main/java/org/amnezia/awg/model/TunnelManager.kt (+10 -10)

📄 Description

What

Track connection status per tunnel and detect reconnects in the Android backend.

Why

The status polling job in AwgQuickBackend only tracked a single currentTunnel, so with multiple tunnels enabled... the first tunnel was left without handshake monitoring and its status stuck at CONNECTING forever. The global StatusCallback did not carry the tunnel identity, so TunnelManager applied the status update to the first UP tunnel in the list instead of the tunnel it belonged to.

Changes

  • StatusCallback now carries the Tunnel the event belongs to.
  • AwgQuickBackend polls all running tunnels (runningConfigs) in a single loop, remembers each tunnel's last handshake time, and:
    • reports CONNECTED on the fresh-handshake transition;
    • reports CONNECTING when a tunnel's handshake goes stale (180 s, matching WireGuard's Reject-After-Time).
  • TunnelManager routes the status update to the exact tunnel by name.
  • GoBackend adapted to the new callback signature.

Also fixed a latent ConcurrentModificationException in the status snapshot path.

Testing performed

  • Multiple tunnels enabled simultaneously on device; each shows independent CONNECTING → CONNECTED → (after tunnel drop) CONNECTING state.
  • Reconnect after network stack reset shows CONNECTING then CONNECTED again.
  • Single-tunnel case regression-tested.

🔄 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/amneziawg-android/pull/90 **Author:** [@erophey7](https://github.com/erophey7) **Created:** 8/8/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `fix/multi-tunnel-status` --- ### 📝 Commits (1) - [`104b3de`](https://github.com/amnezia-vpn/amneziawg-android/commit/104b3de733c26b8d7373ec83e361b59fd2e3d174) backend: track connection status per tunnel and detect reconnects ### 📊 Changes **4 files changed** (+62 additions, -45 deletions) <details> <summary>View changed files</summary> 📝 `tunnel/src/main/java/org/amnezia/awg/backend/AwgQuickBackend.java` (+47 -32) 📝 `tunnel/src/main/java/org/amnezia/awg/backend/GoBackend.java` (+1 -1) 📝 `tunnel/src/main/java/org/amnezia/awg/backend/StatusCallback.java` (+4 -2) 📝 `ui/src/main/java/org/amnezia/awg/model/TunnelManager.kt` (+10 -10) </details> ### 📄 Description ## What Track connection status **per tunnel** and detect reconnects in the Android backend. ## Why The status polling job in `AwgQuickBackend` only tracked a single `currentTunnel`, so with multiple tunnels enabled... the first tunnel was left without handshake monitoring and its status stuck at CONNECTING forever. The global `StatusCallback` did not carry the tunnel identity, so `TunnelManager` applied the status update to the first UP tunnel in the list instead of the tunnel it belonged to. ## Changes - `StatusCallback` now carries the `Tunnel` the event belongs to. - `AwgQuickBackend` polls all running tunnels (`runningConfigs`) in a single loop, remembers each tunnel's last handshake time, and: - reports CONNECTED on the fresh-handshake transition; - reports CONNECTING when a tunnel's handshake goes stale (180 s, matching WireGuard's Reject-After-Time). - `TunnelManager` routes the status update to the exact tunnel by name. - `GoBackend` adapted to the new callback signature. Also fixed a latent `ConcurrentModificationException` in the status snapshot path. ## Testing performed - Multiple tunnels enabled simultaneously on device; each shows independent CONNECTING → CONNECTED → (after tunnel drop) CONNECTING state. - Reconnect after network stack reset shows CONNECTING then CONNECTED again. - Single-tunnel case regression-tested. --- <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/amneziawg-android#95
No description provided.