github aeroxy/tunnix 0.2.2
tunnix v0.2.2

9 hours ago

1. High-Level Summary (TL;DR)

  • Impact: Medium - Enhances client resilience by allowing hot-reloading of the server_url without restarting the tunnel process.
  • Key Changes:
    • Moved server_base_url from the static Tunnel struct to the dynamically reloadable HotClientConfig.
    • Updated the configuration watcher to detect changes to the server URL and trigger a tunnel reconnect.
    • Modified the SSE read loop and HTTP POST methods to fetch the latest server URL dynamically.
    • Added a comprehensive integration test to verify the reconnect behavior upon URL changes.

2. Visual Overview (Code & Logic Map)

Config Watcher and Tunnel-2026-05-12-150835

3. Detailed Change Analysis

Hot Configuration Reloading

  • Component Name: config_watcher_client (Source: src/reload.rs)
  • What Changed: Added server_base_url to the HotClientConfig struct so it can be safely swapped at runtime. The config watcher now checks if the new server URL differs from the currently loaded one. If a change is detected, it flags a reconnect (needs_reconnect = true) and updates the in-memory configuration.

Tunnel Connection Logic

  • Component Name: Tunnel (Source: src/tunnel.rs)
  • What Changed: The Tunnel struct no longer holds a static server_base_url. Instead, network methods like sse_read_loop() and try_post() dynamically load the latest URL via self.hot.load().server_base_url. This guarantees that if the config file is updated mid-session, new connections will point to the newly specified server.

Structural Refactoring

Original Location New Location Reason
Tunnel struct HotClientConfig struct Enables dynamic hot-reloading of the target server URL without recreating the entire tunnel object.

Integration Testing

  • Component Name: reconnect_on_url_change.rs
  • What Changed: Introduced a new integration test suite. This test verifies the end-to-end hot-reload scenario:
    1. Starts Server A and Client connecting to A.
    2. Starts Server B.
    3. Rewrites the client's configuration file to point to Server B.
    4. Asserts that the client detects the change, logs the reconnection, and successfully routes traffic to Server B.

4. Impact & Risk Assessment

  • Breaking Changes: None. This is a purely additive resilience feature.
  • Testing Suggestions:
    • Verify the hot-reload behavior in a staging environment by changing the server_url in the configuration file while active traffic is flowing.
    • Check for potential memory leaks or hanging connections if the previous SSE stream is not cleanly closed during the reconnect phase.

Don't miss a new tunnix release

NewReleases is sending notifications on new releases.