feat(client): show gateway peer in startup status
The relay welcome now carries the gateway peer id, but the first Windows client startup line still only showed whether a gateway was connected. Surface the peer id there when it is known so manual MVP testers can record it even before or without relying on a later lifecycle catch-up line. Keep the older yes/no text when a gateway is connected but the peer id is not available, which preserves useful output for older welcome payloads. Test Plan: - cargo fmt --check - cargo test -p lanparty-client-win gateway_status - cargo clippy -p lanparty-client-win --all-targets -- -D warnings - git diff --check - git diff --cached --check Refs: MVP manual validation
This commit is contained in:
+1
-1
@@ -171,7 +171,7 @@ Expected client output:
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
prepared TAP adapter ... MAC ... configured and media disconnected before relay connect
|
prepared TAP adapter ... MAC ... configured and media disconnected before relay connect
|
||||||
lanparty-client-win connected as peer ...
|
lanparty-client-win connected as peer ...; LAN gateway connected yes (peer ...)
|
||||||
relay event: LAN gateway connected as peer ...
|
relay event: LAN gateway connected as peer ...
|
||||||
relay route pinned before TAP ...
|
relay route pinned before TAP ...
|
||||||
relay route verified after TAP activation ...
|
relay route verified after TAP activation ...
|
||||||
|
|||||||
@@ -193,7 +193,10 @@ async fn main() -> Result<()> {
|
|||||||
session.welcome().room_id(),
|
session.welcome().room_id(),
|
||||||
session.welcome().effective_tap_mtu(),
|
session.welcome().effective_tap_mtu(),
|
||||||
session.welcome().mode(),
|
session.welcome().mode(),
|
||||||
yes_no(session.welcome().gateway_connected())
|
gateway_status_label(
|
||||||
|
session.welcome().gateway_connected(),
|
||||||
|
session.welcome().gateway_peer_id()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let relay_route_pin = match pin_relay_route_before_tap(session.config().relay_addr().ip()) {
|
let relay_route_pin = match pin_relay_route_before_tap(session.config().relay_addr().ip()) {
|
||||||
@@ -755,6 +758,14 @@ const fn yes_no(value: bool) -> &'static str {
|
|||||||
if value { "yes" } else { "no" }
|
if value { "yes" } else { "no" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn gateway_status_label(gateway_connected: bool, gateway_peer_id: Option<u32>) -> String {
|
||||||
|
match (gateway_connected, gateway_peer_id) {
|
||||||
|
(true, Some(peer_id)) => format!("yes (peer {peer_id})"),
|
||||||
|
(true, None) => "yes".to_owned(),
|
||||||
|
(false, _) => "no".to_owned(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn optional_label<T: std::fmt::Display>(value: Option<T>) -> String {
|
fn optional_label<T: std::fmt::Display>(value: Option<T>) -> String {
|
||||||
value.map_or_else(|| "unknown".to_string(), |value| value.to_string())
|
value.map_or_else(|| "unknown".to_string(), |value| value.to_string())
|
||||||
}
|
}
|
||||||
@@ -1243,6 +1254,13 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn formats_gateway_status_with_welcome_peer_id() {
|
||||||
|
assert_eq!(gateway_status_label(true, Some(7)), "yes (peer 7)");
|
||||||
|
assert_eq!(gateway_status_label(true, None), "yes");
|
||||||
|
assert_eq!(gateway_status_label(false, Some(7)), "no");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn formats_missing_client_diagnostics_as_unknown() {
|
fn formats_missing_client_diagnostics_as_unknown() {
|
||||||
let diagnostics = ClientDiagnostics::new(
|
let diagnostics = ClientDiagnostics::new(
|
||||||
|
|||||||
Reference in New Issue
Block a user