pub fn advertised_endpoints(bound: &str) -> Vec<String>Expand description
The endpoints a server bound at bound (host:port) advertises. A bind is what the
socket was asked for; an endpoint is what another machine can dial, and the two differ
exactly when the bind is unspecified — nobody can reach 0.0.0.0, so that bind is
expanded into the interfaces it actually listens on. A bind this cannot parse is
passed through unchanged, because a name this process cannot resolve may still be one
its peers can.
use majordomus_cli::mesh::address::advertised_endpoints;
assert_eq!(advertised_endpoints("127.0.0.1:8742"), ["127.0.0.1:8742"]);
// the unspecified bind never advertises itself, and keeps the port it was given
let wide = advertised_endpoints("0.0.0.0:8742");
assert!(wide.iter().all(|e| e.ends_with(":8742") && !e.starts_with("0.0.0.0")));
assert!(!wide.is_empty(), "loopback stands in when no interface is up");
// a host this process cannot parse is still a host its peers may know
assert_eq!(advertised_endpoints("gateway.local:8742"), ["gateway.local:8742"]);