function isAddressv6GlobalUnicast
isAddressv6GlobalUnicast(address: bigint): boolean

Checks if an IPv6 address is a global unicast address (RFC 4291).

Global unicast range: 2000::/3 (2000:: – 3fff:ffff:...:ffff)

Note: This includes sub-ranges like documentation (2001:db8::/32), Teredo (2001::/32), and benchmarking (2001:2::/48). Use the more specific classifiers or classifyAddressv6 to distinguish them.

Examples

Example 1

import { assert, assertEquals } from "@std/assert";
import { isAddressv6GlobalUnicast } from "@hertzg/ip/classifyv6";
import { parseAddressv6 } from "@hertzg/ip/addressv6";

assert(isAddressv6GlobalUnicast(parseAddressv6("2607:f8b0:4004:800::200e").address));
assert(isAddressv6GlobalUnicast(parseAddressv6("2001:db8::1").address)); // also documentation
assertEquals(isAddressv6GlobalUnicast(parseAddressv6("fe80::1").address), false);

Parameters

address: bigint

The address as a 128-bit bigint

Return Type

boolean

true if the address is in the global unicast range

Usage

import { isAddressv6GlobalUnicast } from "classifyv6.ts";