From f88c8a94f8b42f3cbccced64036887ba0e98abcf Mon Sep 17 00:00:00 2001 From: ddidderr Date: Thu, 21 May 2026 19:08:07 +0200 Subject: [PATCH] feat(client): report relay route before TAP activation Use the new route snapshot helper in the Windows client startup path before the TAP adapter is opened and marked connected. The client now reports the current relay destination route: selected source address, next hop, interface index, interface LUID, route prefix, and metric. This is still diagnostic only. Route pinning remains unwired, and route lookup failure is a warning so manual TAP frame-pump testing is not blocked by a route inspection failure. Once mutation is implemented, this snapshot gives the code the pre-TAP interface data it needs to preserve the real internet path. Verification note: I attempted to check `lanparty-client-win` for `x86_64-pc-windows-msvc`, but this host still lacks the Windows C headers needed by `ring`; the build stops at `assert.h` before the binary crate can be typechecked for Windows. Test Plan: - cargo fmt --check - cargo test --workspace - cargo clippy --workspace --all-targets -- -D warnings - cargo check -p lanparty-client-route --target x86_64-pc-windows-msvc - cargo clippy -p lanparty-client-route --target x86_64-pc-windows-msvc -- -D warnings - git diff --check Refs: PLAN.md --- Cargo.lock | 1 + README.md | 11 +++++----- crates/lanparty-client-win/Cargo.toml | 1 + crates/lanparty-client-win/src/main.rs | 30 ++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0fd5080..0fd01cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -470,6 +470,7 @@ dependencies = [ "anyhow", "clap", "lanparty-client-core", + "lanparty-client-route", "lanparty-client-tap", "lanparty-ctrl", "lanparty-proto", diff --git a/README.md b/README.md index 89541f2..74f9536 100644 --- a/README.md +++ b/README.md @@ -130,8 +130,9 @@ cargo run -p lanparty-client-win -- \ The Windows client binary currently connects to the relay as `role = client` with a generated locally administered virtual MAC persisted in `lanparty-client-identity.json`, completes the control-stream hello/welcome -handshake, and then bridges Ethernet frames between the relay and the first -TAP-Windows6 adapter until shutdown. `--virtual-mac` can still override the -stored identity for manual testing. On Windows it marks the TAP media -connected and reports the driver MAC/MTU before forwarding frames. Route -pinning and automatic TAP MAC/MTU configuration are not wired yet. +handshake, snapshots the current relay route, and then bridges Ethernet frames +between the relay and the first TAP-Windows6 adapter until shutdown. +`--virtual-mac` can still override the stored identity for manual testing. On +Windows it marks the TAP media connected and reports the driver MAC/MTU before +forwarding frames. Route pinning and automatic TAP MAC/MTU configuration are +not wired yet. diff --git a/crates/lanparty-client-win/Cargo.toml b/crates/lanparty-client-win/Cargo.toml index 3060cc8..d26509f 100644 --- a/crates/lanparty-client-win/Cargo.toml +++ b/crates/lanparty-client-win/Cargo.toml @@ -12,4 +12,5 @@ lanparty-proto = { path = "../lanparty-proto" } tokio.workspace = true [target.'cfg(windows)'.dependencies] +lanparty-client-route = { path = "../lanparty-client-route" } lanparty-client-tap = { path = "../lanparty-client-tap" } diff --git a/crates/lanparty-client-win/src/main.rs b/crates/lanparty-client-win/src/main.rs index a8b389a..f34b76c 100644 --- a/crates/lanparty-client-win/src/main.rs +++ b/crates/lanparty-client-win/src/main.rs @@ -13,6 +13,8 @@ use lanparty_client_core::{ ClientIdentity, ClientIdentityStore, ClientSession, ClientSessionConfig, connect_client, }; #[cfg(windows)] +use lanparty_client_route::RouteSnapshot; +#[cfg(windows)] use lanparty_client_tap::TapAdapter; use lanparty_ctrl::RoomCode; use lanparty_proto::MacAddr; @@ -106,6 +108,7 @@ async fn main() -> Result<()> { #[cfg(windows)] async fn run_client(session: &ClientSession) -> Result<()> { + log_relay_route_before_tap(session.config().relay_addr().ip()); let tap = open_tap_adapter(session)?; println!("bridging TAP frames; route pinning is not wired yet; press Ctrl-C to stop"); @@ -125,6 +128,33 @@ async fn run_client(session: &ClientSession) -> Result<()> { .context("failed to wait for Ctrl-C") } +#[cfg(windows)] +fn log_relay_route_before_tap(destination: std::net::IpAddr) { + match lanparty_client_route::best_route_to(destination) { + Ok(route) => print_relay_route(&route), + Err(error) => eprintln!( + "failed to inspect relay route before TAP activation; route pinning is not wired yet: {error:#}" + ), + } +} + +#[cfg(windows)] +fn print_relay_route(route: &RouteSnapshot) { + println!( + "relay route before TAP: destination {} source {} next hop {} interface index {} LUID {} prefix {}/{} metric {}", + route.destination(), + route.source(), + route + .next_hop() + .map_or_else(|| "on-link".to_string(), |next_hop| next_hop.to_string()), + route.interface_index(), + route.interface_luid(), + route.route_prefix(), + route.route_prefix_len(), + route.metric() + ); +} + #[cfg(windows)] fn open_tap_adapter(session: &ClientSession) -> Result { let tap = lanparty_client_tap::open_first_adapter()?;