Returns `true` if `ip` is a known cloud instance metadata endpoint that must never be exempted from SSRF blocking. IPv4-mapped IPv6 addresses (e.g. `::ffff:169.254.169.254`) are normalized to their embedded IPv4 representation before comparison, so the invariant holds regardless of how the address is represented.
(ip: IpAddr)
| 2264 | /// to their embedded IPv4 representation before comparison, so the invariant |
| 2265 | /// holds regardless of how the address is represented. |
| 2266 | fn is_cloud_metadata_ip(ip: IpAddr) -> bool { |
| 2267 | match ip { |
| 2268 | IpAddr::V4(_) => CLOUD_METADATA_IPS.contains(&ip), |
| 2269 | IpAddr::V6(v6) => v6 |
| 2270 | .to_ipv4_mapped() |
| 2271 | .is_some_and(|v4| CLOUD_METADATA_IPS.contains(&IpAddr::V4(v4))), |
| 2272 | } |
| 2273 | } |
| 2274 | |
| 2275 | /// Read the proxy's own `/etc/hosts` at startup and return the IP mapped to |
| 2276 | /// `host.openshell.internal`, if present and safe. |
no outgoing calls