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:
@@ -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" }
|
||||
|
||||
@@ -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()?;
|
||||
|
||||
Reference in New Issue
Block a user