Skip to main content

is_loopback

Function is_loopback 

Source
pub fn is_loopback(url: &Url) -> bool
Expand description

Whether url names this machine and nowhere else.

localhost by name, or any address the standard library calls a loopback address, which covers 127.0.0.0/8 and ::1 without this having to enumerate either.

The host is taken from Url::host rather than Url::host_str. The string form of an IPv6 host keeps the brackets the URL syntax requires, [::1] parses as no address at all, and a check written against it refuses a client listening on IPv6 loopback.