Skip to main content

is_loopback_host

Function is_loopback_host 

Source
pub fn is_loopback_host(host: &str) -> bool
Expand description

Whether host refers to the loopback interface.

Covers the literal localhost alongside any address that parses as an IP and is loopback, so ::1 and 127.0.0.2 are caught as well as 127.0.0.1.

Accepts a bare host, with or without a port and with or without IPv6 brackets — callers reach this both with a configured bind host and with a raw Host header, and the two are spelled differently.