()
| 2847 | } |
| 2848 | |
| 2849 | fn detect_lan_ip() -> Option<IpAddr> { |
| 2850 | for target in ["8.8.8.8:80", "1.1.1.1:80"] { |
| 2851 | let socket = UdpSocket::bind((Ipv4Addr::UNSPECIFIED, 0)).ok()?; |
| 2852 | if socket.connect(target).is_err() { |
| 2853 | continue; |
| 2854 | } |
| 2855 | let ip = socket.local_addr().ok()?.ip(); |
| 2856 | if !ip.is_loopback() && !ip.is_unspecified() { |
| 2857 | return Some(ip); |
| 2858 | } |
| 2859 | } |
| 2860 | None |
| 2861 | } |
| 2862 | |
| 2863 | fn detect_tailscale_ip() -> Option<IpAddr> { |
| 2864 | detect_tailscale_ip_from_cli().or_else(detect_tailscale_ip_from_ifconfig) |
no test coverage detected