pub fn chia_peer_endpoint(ip: &str, port: u16) -> StringExpand description
Join a canonical peer ip to a port, bracketing IPv6 as RFC 3986 requires.
The one place a peer address and a port are ever concatenated. Formatting "{ip}:{port}" by
hand is the bug this exists to prevent: ::1 and 8444 render as ::1:8444, which is not a
malformed string a parser rejects — it is a DIFFERENT valid IPv6 address, so the mistake
survives validation and silently retargets the peer.
use dig_node_control_interface::params::chia_peer_endpoint;
assert_eq!(chia_peer_endpoint("::1", 8444), "[::1]:8444");
assert_eq!(chia_peer_endpoint("203.0.113.7", 8444), "203.0.113.7:8444");