(target: &PairingTarget)
| 2088 | } |
| 2089 | |
| 2090 | fn pairing_addresses(target: &PairingTarget) -> Vec<PairingAddress> { |
| 2091 | let mut addresses = Vec::new(); |
| 2092 | push_pairing_address( |
| 2093 | &mut addresses, |
| 2094 | "local", |
| 2095 | http_url_for_host("127.0.0.1", target.port), |
| 2096 | ); |
| 2097 | |
| 2098 | let advertise_host = target |
| 2099 | .advertise_host |
| 2100 | .as_deref() |
| 2101 | .filter(|host| !host.trim().is_empty()); |
| 2102 | if let Some(host) = advertise_host { |
| 2103 | let kind = host |
| 2104 | .parse::<IpAddr>() |
| 2105 | .ok() |
| 2106 | .filter(|ip| is_tailscale_ip(*ip)) |
| 2107 | .map(|_| "tailscale") |
| 2108 | .unwrap_or("lan"); |
| 2109 | if host != "127.0.0.1" && host != "localhost" { |
| 2110 | push_pairing_address(&mut addresses, kind, http_url_for_host(host, target.port)); |
| 2111 | } |
| 2112 | } |
| 2113 | |
| 2114 | if let Some(lan_ip) = detect_lan_ip() { |
| 2115 | push_pairing_address( |
| 2116 | &mut addresses, |
| 2117 | "lan", |
| 2118 | http_url_for_host(&lan_ip.to_string(), target.port), |
| 2119 | ); |
| 2120 | } |
| 2121 | |
| 2122 | if let Some(tailscale_ip) = detect_tailscale_ip() { |
| 2123 | push_pairing_address( |
| 2124 | &mut addresses, |
| 2125 | "tailscale", |
| 2126 | http_url_for_host(&tailscale_ip.to_string(), target.port), |
| 2127 | ); |
| 2128 | } |
| 2129 | |
| 2130 | addresses |
| 2131 | } |
| 2132 | |
| 2133 | fn push_pairing_address(addresses: &mut Vec<PairingAddress>, kind: &'static str, url: String) { |
| 2134 | if addresses.iter().any(|address| address.url == url) { |
no test coverage detected