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
This commit is contained in:
2026-05-21 19:08:07 +02:00
parent 5001f3c35c
commit f88c8a94f8
4 changed files with 38 additions and 5 deletions
Generated
+1
View File
@@ -470,6 +470,7 @@ dependencies = [
"anyhow",
"clap",
"lanparty-client-core",
"lanparty-client-route",
"lanparty-client-tap",
"lanparty-ctrl",
"lanparty-proto",
+6 -5
View File
@@ -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.
+1
View File
@@ -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" }
+30
View File
@@ -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<lanparty_client_tap::TapAdapter> {
let tap = lanparty_client_tap::open_first_adapter()?;