Return true iff the host string parses as an IP in a reserved link-local range (IPv4 `169.254.0.0/16` or IPv6 `fe80::/10`). Hostname-only strings (not parseable as IPs) return false. We don't perform DNS resolution at validation time; the model evaluates the policy as written.
(host: &str)
| 49 | /// perform DNS resolution at validation time; the model evaluates the |
| 50 | /// policy as written. |
| 51 | pub(crate) fn is_link_local(host: &str) -> bool { |
| 52 | match host.parse::<IpAddr>() { |
| 53 | Ok(IpAddr::V4(v4)) => v4.is_link_local(), |
| 54 | Ok(IpAddr::V6(v6)) => v6.is_unicast_link_local(), |
| 55 | Err(_) => false, |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | /// Return true for static cloud metadata hostnames that should be treated like |
| 60 | /// link-local metadata reach without performing DNS resolution. |
no outgoing calls
no test coverage detected