diff --git a/src/remote.rs b/src/remote.rs index 3b3c58a..f5814eb 100644 --- a/src/remote.rs +++ b/src/remote.rs @@ -1916,8 +1916,8 @@ fn base(url: &str) -> String { /// computer's key may go to it unencrypted. `host` is the name in the URL and `addrs` what it /// resolved to — the very addresses about to be connected to (a name can answer differently the /// second time, so the check is made at the moment of connecting, on what it answered then). -/// Off the air: this machine (a loopback address; for `localhost` only its loopback addresses -/// are kept, and it is refused when none is); a one-word name (`one_word_name`), taken to be another +/// Off the air: this machine (every resolved address a loopback one; for `localhost` only its +/// loopback addresses are kept, and it is refused when none is); a one-word name (`one_word_name`), taken to be another /// container of the same Docker network (http://relay:8080 — see SECURITY.md about such names on /// an ordinary network); or a server reached through this machine's Tailscale tunnel /// (lantls::tunnel_route: Tailscale addresses whose route leaves from the tunnel; one with no @@ -1925,13 +1925,13 @@ fn base(url: &str) -> String { /// isn't Tailscale: a Wi-Fi can hand those out. The answer is the addresses to connect to. pub(crate) fn plain_hop(host: &str, addrs: &[std::net::SocketAddr]) -> Result, String> { let host = host.trim_start_matches('[').trim_end_matches(']'); - let refuse = || Err(format!("帳號伺服器 {host} 用的是 http://,這台到它的路不經過 Tailscale:帳號密碼和這台電腦的金鑰會在網路上明文傳送,所以先不連(之後會再試)。請改用 https://,或等 Tailscale 連上")); + let refuse = || Err(format!("帳號伺服器 {host} 用的是 http://,這台到它的路不經過 Tailscale:帳號密碼和這台電腦的金鑰會在網路上明文傳送,所以先不連。請改用 https://,或等 Tailscale 連上")); // `localhost`: only its loopback addresses (an older Mac's hosts file adds fe80::1%lo0, and // one could send it anywhere); none at all, and it isn't this machine. if host.eq_ignore_ascii_case("localhost") { let here: Vec = addrs.iter().filter(|a| a.ip().to_canonical().is_loopback()).copied().collect(); if here.is_empty() && !addrs.is_empty() { - return Err("帳號伺服器的網址是 localhost,可是這台電腦把 localhost 查到別的位址(看 /etc/hosts):帳號密碼和這台電腦的金鑰都不會送過去,所以先不連(之後會再試)".to_string()); + return Err("帳號伺服器的網址是 http://localhost,可是這台電腦把 localhost 查到別的位址(看 /etc/hosts):帳號密碼和這台電腦的金鑰都不會送過去,所以先不連".to_string()); } return Ok(here); } @@ -3230,6 +3230,9 @@ mod tests { assert_eq!(kept, both[1..].to_vec()); let e = crate::lantls::with_tunnels(&[], || plain_hop("localhost", &[link_local])).unwrap_err(); assert!(e.contains("localhost") && e.contains("/etc/hosts"), "{e}"); + // Said as it is when the http client's resolver refuses (not 「網路連線出了問題」). + let refused = ureq::Error::Io(std::io::Error::new(std::io::ErrorKind::PermissionDenied, e.clone())); + assert_eq!(why_unreachable(&refused), e); // (A number that does land on this machine is still this machine.) assert!(plain_hop("0x7f000001", &at("127.0.0.1")).is_ok()); }