Files
softlan-vpn/crates/lanparty-gateway/src/main.rs
T
ddidderr 6a18daac3a feat(ctrl): report connection mode in welcome
PLAN.md calls out room modes such as relay, direct-p2p, and relay fallback so
future transport choices can fit the protocol. Add an explicit ConnectionMode
field to ServerWelcome and default it to relay for existing decoded welcomes.

The relay still operates only in relay mode today. Client and gateway startup
logs now print the selected mode, which makes the current relay path visible
without changing routing or forwarding behavior.

Test Plan:
- cargo fmt --check
- cargo test -p lanparty-ctrl server_welcome -- --nocapture
- cargo test -p lanparty-client-win -p lanparty-gateway
- cargo test --workspace
- cargo clippy --workspace --all-targets -- -D warnings
- git diff --check

Refs: PLAN.md
2026-05-21 21:43:44 +02:00

40 lines
1.2 KiB
Rust

use clap::Parser;
#[cfg(target_os = "linux")]
use lanparty_gateway::PacketSocket;
use lanparty_gateway::{GatewayArgs, connect_gateway};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = GatewayArgs::parse().into_config()?;
println!(
"lanparty-gateway connecting interface {} to relay {} room {}",
config.interface(),
config.relay_addr(),
config.room()
);
let gateway = connect_gateway(config).await?;
println!(
"lanparty-gateway connected as peer {} in room id {} with TAP MTU {} over {}",
gateway.welcome().peer_id(),
gateway.welcome().room_id(),
gateway.welcome().effective_tap_mtu(),
gateway.welcome().mode()
);
#[cfg(target_os = "linux")]
{
let socket = PacketSocket::open(gateway.config().interface())?;
println!(
"lanparty-gateway opened AF_PACKET socket on {} (ifindex {})",
socket.interface(),
socket.interface_index()
);
println!("lanparty-gateway bridging frames; press Ctrl-C to stop");
gateway.bridge_until_shutdown(socket).await?;
}
#[cfg(not(target_os = "linux"))]
anyhow::bail!("lanparty-gateway requires Linux AF_PACKET support");
Ok(())
}