Standardize TunnelManager signals: tunnelUp/tunnelDown/tunnelError
This commit is contained in:
parent
693c20d6a5
commit
6900f17804
1 changed files with 20 additions and 13 deletions
|
|
@ -1,9 +1,13 @@
|
||||||
// tunnelmanager.h — Platform-agnostic interface for the WireGuard tunnel.
|
// tunnelmanager.h — Platform-agnostic interface for the WireGuard tunnel.
|
||||||
//
|
//
|
||||||
// Platform implementations:
|
// Platform implementations:
|
||||||
// tunnelmanager_mac.mm — macOS (utun + boringtun, no root required for TUN open)
|
// tunnelmanager_mac.mm — macOS (utun + boringtun, no root for TUN open)
|
||||||
// tunnelmanager_linux.cpp — Linux (kernel WireGuard via wgctrl, future)
|
// tunnelmanager_linux.cpp — Linux (/dev/net/tun + boringtun userspace,
|
||||||
// tunnelmanager_win.cpp — Windows (Wintun + boringtun, future)
|
// requires CAP_NET_ADMIN or root)
|
||||||
|
// tunnelmanager_win.cpp — Windows (Wintun + boringtun, requires Admin)
|
||||||
|
//
|
||||||
|
// The QML layer talks to TunnelManager indirectly via DragonRelayBackend.
|
||||||
|
// All signals are emitted on the QObject's thread (the Qt main thread).
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
@ -25,14 +29,12 @@ public:
|
||||||
/// Bring up the WireGuard tunnel described by cfg.
|
/// Bring up the WireGuard tunnel described by cfg.
|
||||||
///
|
///
|
||||||
/// This call returns quickly; the tunnel comes up asynchronously.
|
/// This call returns quickly; the tunnel comes up asynchronously.
|
||||||
/// Listen to connected() / error() for status. The first thing that
|
/// Listen for tunnelUp() / tunnelError() to observe the result.
|
||||||
/// happens is a handshake initiation — if the server is reachable the
|
|
||||||
/// connected() signal fires within ~500 ms.
|
|
||||||
///
|
///
|
||||||
/// Calling start() while already running silently stops the previous tunnel
|
/// Calling start() while already running silently stops the previous
|
||||||
/// first (equivalent to stop() then start()).
|
/// tunnel first (equivalent to stop() then start()).
|
||||||
///
|
///
|
||||||
/// @return false immediately if cfg.isValid() == false (error() is also emitted).
|
/// Returns false immediately and emits tunnelError() if cfg.isValid() is false.
|
||||||
bool start(const WireGuardConfig &cfg);
|
bool start(const WireGuardConfig &cfg);
|
||||||
|
|
||||||
/// Tear down the tunnel synchronously. Safe to call when not running.
|
/// Tear down the tunnel synchronously. Safe to call when not running.
|
||||||
|
|
@ -41,18 +43,23 @@ public:
|
||||||
// ── State ──────────────────────────────────────────────────────────────
|
// ── State ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
bool isRunning() const { return m_running; }
|
bool isRunning() const { return m_running; }
|
||||||
QString errorString() const { return m_error; }
|
QString errorString() const { return m_error; }
|
||||||
|
|
||||||
/// The bare WireGuard IP assigned to this peer, e.g. "10.99.0.2".
|
/// The bare WireGuard IP assigned to this peer, e.g. "10.99.0.2".
|
||||||
/// Empty string when not connected.
|
/// Empty string when not connected.
|
||||||
QString localAddress() const { return m_localAddr; }
|
QString localAddress() const { return m_localAddr; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/// Emitted after the first successful handshake with the server.
|
/// Emitted once the tunnel is ready to carry traffic.
|
||||||
void connected();
|
/// The argument is the local WireGuard IP (e.g. "10.99.0.2").
|
||||||
|
///
|
||||||
|
/// On macOS this fires after a short post-handshake delay; on Linux and
|
||||||
|
/// Windows it fires once the kernel TUN/Wintun adapter is configured and
|
||||||
|
/// boringtun reports a successful handshake.
|
||||||
|
void tunnelUp(const QString &localIP);
|
||||||
|
|
||||||
/// Emitted when the tunnel is fully torn down.
|
/// Emitted when the tunnel is fully torn down.
|
||||||
void disconnected();
|
void tunnelDown();
|
||||||
|
|
||||||
/// Emitted on any non-recoverable error. The tunnel is stopped.
|
/// Emitted on any non-recoverable error. The tunnel is stopped.
|
||||||
void tunnelError(const QString &message);
|
void tunnelError(const QString &message);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue