Function isPublicAddress

  • True when address, an IPv4 or IPv6 address as text, is a public unicast address: not unspecified, loopback, private, carrier-grade NAT, link-local, unique-local, site-local, multicast, documentation, benchmarking or otherwise reserved, and, for an IPv6 address that carries an IPv4 one (IPv4-mapped, NAT64, 6to4), not one whose IPv4 address is any of those. The deprecated IPv4-compatible form (::/96) is not public whatever it carries. Text that is not an IP address is not public. It is the rule guardedFetch applies to every address a host resolves to, the same rule as isPublicNetworkAddress in @framers/agentos/io/media/images, which it calls.

    Parameters

    • address: string

    Returns boolean

    Example

    isPublicAddress('8.8.8.8');         // true
    isPublicAddress('169.254.169.254'); // false: link-local, where cloud metadata services answer
    isPublicAddress('::ffff:10.0.0.1'); // false: a private IPv4 address inside IPv6