feat(obs): warn on missing client readiness
The friendly client diagnostics reported relay/gateway/IP/broadcast signals, but they still hid two important readiness failures in the dense status line: the relay route was not pinned, or no TAP adapter was available. Those are the kind of states a CLI user or future GUI needs surfaced immediately. Add user diagnostics for an unpinned relay route, a missing TAP adapter, and a TAP adapter that is present but still has no IP address. The existing healthy path stays concise: once the TAP has an address, the diagnostics continue to report that address instead of also saying that the adapter is ready. README now mentions that the short diagnostics include route and TAP readiness warnings. Test Plan: - cargo fmt --check - cargo test -p lanparty-obs -p lanparty-client-win - cargo test --workspace - cargo clippy --workspace --all-targets -- -D warnings - git diff --check - git diff --cached --check Refs: PLAN.md Logging / diagnostics
This commit is contained in:
@@ -385,6 +385,25 @@ impl ClientDiagnostics {
|
||||
UserDiagnostic::new(UserDiagnosticLevel::Warning, "Waiting for LAN gateway")
|
||||
});
|
||||
|
||||
if !self.relay.route_pinned() {
|
||||
diagnostics.push(UserDiagnostic::new(
|
||||
UserDiagnosticLevel::Warning,
|
||||
"Relay route not pinned",
|
||||
));
|
||||
}
|
||||
|
||||
if !self.tap.adapter_found() {
|
||||
diagnostics.push(UserDiagnostic::new(
|
||||
UserDiagnosticLevel::Error,
|
||||
"TAP adapter not found",
|
||||
));
|
||||
} else if self.tap.ip().is_none() {
|
||||
diagnostics.push(UserDiagnostic::new(
|
||||
UserDiagnosticLevel::Warning,
|
||||
"Waiting for TAP IP",
|
||||
));
|
||||
}
|
||||
|
||||
if let Some(message) = tap_ip_user_message(self.tap.ip()) {
|
||||
diagnostics.push(UserDiagnostic::new(UserDiagnosticLevel::Info, message));
|
||||
}
|
||||
@@ -597,10 +616,47 @@ mod tests {
|
||||
.iter()
|
||||
.map(UserDiagnostic::message)
|
||||
.collect::<Vec<_>>(),
|
||||
["Relay not reachable", "Waiting for LAN gateway"]
|
||||
[
|
||||
"Relay not reachable",
|
||||
"Waiting for LAN gateway",
|
||||
"Relay route not pinned",
|
||||
"TAP adapter not found",
|
||||
]
|
||||
);
|
||||
assert_eq!(user_diagnostics[0].level(), UserDiagnosticLevel::Error);
|
||||
assert_eq!(user_diagnostics[1].level(), UserDiagnosticLevel::Warning);
|
||||
assert_eq!(user_diagnostics[2].level(), UserDiagnosticLevel::Warning);
|
||||
assert_eq!(user_diagnostics[3].level(), UserDiagnosticLevel::Error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reports_waiting_for_tap_ip_when_adapter_has_no_address() {
|
||||
let diagnostics = ClientDiagnostics::new(
|
||||
RelayDiagnostics::new(true, true, true),
|
||||
QuicDiagnostics::new(true, Some(1400)),
|
||||
TapDiagnostics::new(
|
||||
true,
|
||||
Some(MacAddr::new([0x02, 1, 2, 3, 4, 5])),
|
||||
Some(1200),
|
||||
None,
|
||||
),
|
||||
TunnelStats::default(),
|
||||
);
|
||||
|
||||
let user_diagnostics = diagnostics.user_diagnostics();
|
||||
|
||||
assert_eq!(
|
||||
user_diagnostics
|
||||
.iter()
|
||||
.map(UserDiagnostic::message)
|
||||
.collect::<Vec<_>>(),
|
||||
[
|
||||
"Connected to relay",
|
||||
"Connected to LAN gateway",
|
||||
"Waiting for TAP IP",
|
||||
]
|
||||
);
|
||||
assert_eq!(user_diagnostics[2].level(), UserDiagnosticLevel::Warning);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user