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(()) }