| 1913 | } |
| 1914 | |
| 1915 | fn service_addresses(metadata: &ServiceMetadata, selector: Option<&str>) -> Vec<PairingAddress> { |
| 1916 | let mut addresses = Vec::new(); |
| 1917 | push_ui_address(&mut addresses, "local", metadata.http_url.clone(), selector); |
| 1918 | |
| 1919 | if let Some(host) = metadata |
| 1920 | .advertise_host |
| 1921 | .as_deref() |
| 1922 | .filter(|host| !host.trim().is_empty()) |
| 1923 | { |
| 1924 | let host = host.trim(); |
| 1925 | if host != "127.0.0.1" && host != "localhost" { |
| 1926 | push_ui_address( |
| 1927 | &mut addresses, |
| 1928 | if is_tailscale_host(host) { |
| 1929 | "tailscale" |
| 1930 | } else { |
| 1931 | "lan" |
| 1932 | }, |
| 1933 | http_url_for_host(host, metadata.port), |
| 1934 | selector, |
| 1935 | ); |
| 1936 | } |
| 1937 | } |
| 1938 | |
| 1939 | if let Some(lan_ip) = detect_lan_ip() { |
| 1940 | push_ui_address( |
| 1941 | &mut addresses, |
| 1942 | "lan", |
| 1943 | http_url_for_host(&lan_ip.to_string(), metadata.port), |
| 1944 | selector, |
| 1945 | ); |
| 1946 | } |
| 1947 | |
| 1948 | if let Some(tailscale_ip) = detect_tailscale_ip() { |
| 1949 | push_ui_address( |
| 1950 | &mut addresses, |
| 1951 | "tailscale", |
| 1952 | http_url_for_host(&tailscale_ip.to_string(), metadata.port), |
| 1953 | selector, |
| 1954 | ); |
| 1955 | } |
| 1956 | |
| 1957 | addresses |
| 1958 | } |
| 1959 | |
| 1960 | fn push_ui_address( |
| 1961 | addresses: &mut Vec<PairingAddress>, |