MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / is_link_local

Function is_link_local

crates/openshell-prover/src/queries.rs:51–57  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

49/// perform DNS resolution at validation time; the model evaluates the
50/// policy as written.
51pub(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.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected