diff --git a/TESTING.md b/TESTING.md index 24b08fe..9117d19 100644 --- a/TESTING.md +++ b/TESTING.md @@ -242,6 +242,10 @@ If the client says `Waiting for TAP IP`, DHCP is not making the full round trip. Check relay/gateway frame logs for broadcast traffic and check that the gateway is on wired Ethernet. +If the client reports a TAP link-local address such as `169.254.x.x`, treat it +the same way: Windows has self-assigned an address, but LAN DHCP did not +complete through the tunnel. + If startup fails with a TAP MAC mismatch, disable/enable the TAP adapter or reinstall TAP-Windows6 so Windows reloads the `NetworkAddress` value. Do not continue with a mismatched MAC. diff --git a/crates/lanparty-obs/src/lib.rs b/crates/lanparty-obs/src/lib.rs index c2d29ef..58dddaf 100644 --- a/crates/lanparty-obs/src/lib.rs +++ b/crates/lanparty-obs/src/lib.rs @@ -434,8 +434,8 @@ impl ClientDiagnostics { )); } - if let Some(message) = tap_ip_user_message(self.tap.ip()) { - diagnostics.push(UserDiagnostic::new(UserDiagnosticLevel::Info, message)); + if let Some(diagnostic) = tap_ip_user_diagnostic(self.tap.ip()) { + diagnostics.push(diagnostic); } if let Some(rtt_ms) = self.quic.relay_rtt_ms() { @@ -456,10 +456,20 @@ impl ClientDiagnostics { } } -fn tap_ip_user_message(ip: Option) -> Option { +fn tap_ip_user_diagnostic(ip: Option) -> Option { match ip { - Some(IpAddr::V4(ip)) if !ip.is_link_local() => Some(format!("DHCP received: {ip}")), - Some(ip) => Some(format!("TAP IP detected: {ip}")), + Some(IpAddr::V4(ip)) if ip.is_link_local() => Some(UserDiagnostic::new( + UserDiagnosticLevel::Warning, + format!("TAP has link-local IP {ip}; waiting for LAN DHCP"), + )), + Some(IpAddr::V4(ip)) => Some(UserDiagnostic::new( + UserDiagnosticLevel::Info, + format!("DHCP received: {ip}"), + )), + Some(ip) => Some(UserDiagnostic::new( + UserDiagnosticLevel::Info, + format!("TAP IP detected: {ip}"), + )), None => None, } } @@ -712,14 +722,21 @@ mod tests { } #[test] - fn avoids_calling_link_local_tap_ip_dhcp() { + fn reports_link_local_tap_ipv4_as_waiting_for_lan_dhcp() { + let diagnostic = tap_ip_user_diagnostic(Some("169.254.10.20".parse().unwrap())).unwrap(); + + assert_eq!(diagnostic.level(), UserDiagnosticLevel::Warning); assert_eq!( - tap_ip_user_message(Some("169.254.10.20".parse().unwrap())), - Some("TAP IP detected: 169.254.10.20".to_string()) - ); - assert_eq!( - tap_ip_user_message(Some("fe80::1".parse().unwrap())), - Some("TAP IP detected: fe80::1".to_string()) + diagnostic.message(), + "TAP has link-local IP 169.254.10.20; waiting for LAN DHCP" ); } + + #[test] + fn reports_ipv6_link_local_tap_ip_without_calling_it_dhcp() { + let diagnostic = tap_ip_user_diagnostic(Some("fe80::1".parse().unwrap())).unwrap(); + + assert_eq!(diagnostic.level(), UserDiagnosticLevel::Info); + assert_eq!(diagnostic.message(), "TAP IP detected: fe80::1"); + } }