Skip to content

feat(health): Configurable tunnel health monitoring and reconnect thresholds (#44) - #45

Open
Vonarian wants to merge 7 commits into
CluvexStudio:mainfrom
Vonarian:feature/health-monitoring
Open

feat(health): Configurable tunnel health monitoring and reconnect thresholds (#44)#45
Vonarian wants to merge 7 commits into
CluvexStudio:mainfrom
Vonarian:feature/health-monitoring

Conversation

@Vonarian

Copy link
Copy Markdown
Contributor

Resolves #44

Summary of Changes

  • Configurable Health Monitoring Flags:

    • --health-interval <n> (AETHER_HEALTH_INTERVAL, default 20s): Controls continuous background check frequency. Set to 0 to disable.
    • --health-fails <n> (AETHER_HEALTH_MAX_FAILS, default 2): Maximum consecutive failed probes before declaring tunnel dead and initiating reconnect.
    • --health-timeout <n> (AETHER_HEALTH_TIMEOUT, default 5s): Timeout per health probe check.
    • --health-url <url> (AETHER_HEALTH_PROBE_URL, default http://www.gstatic.com/generate_204): Custom health probe URL.
    • --reconnect-secs <n> (AETHER_MASQUE_RECONNECT_SECS / AETHER_WG_RECONNECT_SECS, default 2s): Reconnect delay after tunnel exit or failure.
  • Observatory-Style Health Monitor:

    • Implemented background health monitor task in tunnelping.rs that probes active netstack instances periodically.
    • Measures and logs RTT latency per check (e.g. [+] tunnel health check passed (rtt 142ms)).
    • Automatically triggers clean tunnel reconnect upon consecutive_fails >= max_fails.
  • Integration:

    • Integrated into run_masque_tunnel, run_wireguard_tunnel, and run_warp_in_warp via tokio::select!.

Copilot AI review requested due to automatic review settings July 20, 2026 11:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds configurable, continuous tunnel health monitoring (with timeouts and failure thresholds) and integrates it into MASQUE, WireGuard, and warp-in-warp runtimes, while also refining logging verbosity controls.

Changes:

  • Added HealthConfig + background health monitor task that periodically probes a configurable HTTP URL and triggers failure on consecutive probe errors.
  • Wired the health monitor into tunnel run loops via tokio::select! and exposed config via CLI/env (--health-*, AETHER_HEALTH_*), plus unified --reconnect-secs for MASQUE and WireGuard.
  • Adjusted several hot-path logs from debug to trace and introduced AETHER_LOG/--log-level + multi-level -v verbosity parsing.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
aether/src/wireguard.rs Reduces noise by downgrading encapsulation/decapsulation errors to trace.
aether/src/tunnelping.rs Introduces probe target parsing, health config/env wiring, and the background health monitor + tests.
aether/src/quic.rs Downgrades verbose per-packet logs to trace to reduce default log volume.
aether/src/noize.rs Downgrades obfuscation send logs to trace to reduce default log volume.
aether/src/masque_h2.rs Downgrades capsule send/parse logs to trace.
aether/src/main.rs Integrates the health monitor into MASQUE/WireGuard/warp-in-warp lifecycles and switches logging init to AETHER_LOG.
aether/src/cli.rs Adds health-monitoring CLI flags, new logging flags, and unit tests for env/arg parsing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread aether/src/main.rs
Comment thread aether/src/main.rs
Comment thread aether/src/main.rs
Comment thread aether/src/tunnelping.rs
Comment thread aether/src/cli.rs
Comment thread aether/src/cli.rs
@Vonarian

Copy link
Copy Markdown
Contributor Author

Addressed PR review feedback in commit 97892b1:

  1. Task Cancellation Safety: Borrowed join handles (&mut tunnel_task, &mut socks_task, ref mut health_task) in tokio::select! and added explicit .abort() calls on all tasks before returning in run_masque_tunnel, run_wireguard_tunnel, and run_warp_in_warp.
  2. Probe URL Scheme Validation: Updated parse_probe_url to return Result<ProbeTarget> and explicitly reject https:// schemes with an error (https:// health probe URLs are not supported; please use an http:// URL) to avoid implicit scheme downgrades.
  3. Test Env Hermeticity: Added std::env::remove_var calls at the end of test_cli_parse_log_levels and test_cli_parse_health_options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Configurable tunnel health monitoring and reconnect thresholds

2 participants