Skip to main content

is_localhost

Function is_localhost 

Source
pub fn is_localhost(addr: &SocketAddr) -> bool
Expand description

Checks if a socket address is bound to localhost (127.0.0.1 or ::1).

This is used to validate that TLS-enabled services don’t bind to localhost, since Caddy runs in a separate container and cannot reach localhost addresses.

§Returns

true if the address is IPv4 localhost (127.0.0.1) or IPv6 localhost (::1), false otherwise.

§Note

This intentionally checks only exact localhost addresses (127.0.0.1 and ::1), not the entire 127.0.0.0/8 loopback range, as per design decision.