feat(ctrl): report gateway presence in welcome

ServerWelcome now carries an initial gateway_connected flag with serde defaulting
for older welcome payloads. The relay sets it from room admission state so a
gateway sees itself as connected, clients joining behind an existing gateway see
yes, and clients that arrive first see no.

The Windows client prints that handshake fact at startup. This does not replace
the later peer-event stream; it gives phase-1 diagnostics an immediate answer
for whether the relay already has a LAN gateway in the room.

Test Plan:
- cargo fmt --check
- cargo test -p lanparty-ctrl -p lanparty-relay -p lanparty-client-core \
  -p lanparty-client-win
- cargo clippy -p lanparty-ctrl -p lanparty-relay -p lanparty-client-core \
  -p lanparty-client-win --all-targets -- -D warnings
- cargo test --workspace
- cargo clippy --workspace --all-targets -- -D warnings
- git diff --check

Refs: PLAN.md
This commit is contained in:
2026-05-21 20:24:14 +02:00
parent c6dbb78cfc
commit 0824f60548
5 changed files with 44 additions and 4 deletions
+22
View File
@@ -189,6 +189,8 @@ pub struct ServerWelcome {
room_id: u64,
peer_id: u32,
effective_tap_mtu: u16,
#[serde(default)]
gateway_connected: bool,
}
impl ServerWelcome {
@@ -209,9 +211,16 @@ impl ServerWelcome {
room_id,
peer_id,
effective_tap_mtu,
gateway_connected: false,
})
}
#[must_use]
pub const fn with_gateway_connected(mut self, gateway_connected: bool) -> Self {
self.gateway_connected = gateway_connected;
self
}
pub fn validate(&self) -> Result<(), ControlError> {
if self.protocol_version != CONTROL_PROTOCOL_VERSION {
return Err(ControlError::UnsupportedVersion {
@@ -253,6 +262,11 @@ impl ServerWelcome {
pub const fn effective_tap_mtu(&self) -> u16 {
self.effective_tap_mtu
}
#[must_use]
pub const fn gateway_connected(&self) -> bool {
self.gateway_connected
}
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
@@ -489,6 +503,14 @@ mod tests {
));
}
#[test]
fn server_welcome_reports_gateway_presence() {
let welcome = ServerWelcome::new(1, 2, MIN_USEFUL_TAP_MTU as u16).unwrap();
assert!(!welcome.gateway_connected());
assert!(welcome.with_gateway_connected(true).gateway_connected());
}
#[test]
fn peer_info_enforces_role_mac_rules() {
let client = PeerInfo::new(7, Role::Client, Some(client_mac())).unwrap();