Functional Weave
Code in Python

net.ip-classify@1.0.0

vectors.json

7,609 bytes · view raw

[
  {"name": "IPv4 loopback", "args": ["127.0.0.1"], "expect": {"address": "127.0.0.1", "version": 4, "category": "loopback", "name": "Loopback", "block": "127.0.0.0/8", "rfc": "RFC 1122", "globallyReachable": false}},
  {"name": "10/8 private", "args": ["10.1.2.3"], "expect": {"address": "10.1.2.3", "version": 4, "category": "private", "name": "Private-Use", "block": "10.0.0.0/8", "rfc": "RFC 1918", "globallyReachable": false}},
  {"name": "172.16/12 private, not on an octet boundary", "args": ["172.20.0.1"], "expect": {"address": "172.20.0.1", "version": 4, "category": "private", "name": "Private-Use", "block": "172.16.0.0/12", "rfc": "RFC 1918", "globallyReachable": false}},
  {"name": "192.168/16 private", "args": ["192.168.1.10"], "expect": {"address": "192.168.1.10", "version": 4, "category": "private", "name": "Private-Use", "block": "192.168.0.0/16", "rfc": "RFC 1918", "globallyReachable": false}},
  {"name": "carrier-grade NAT shared space", "args": ["100.64.0.1"], "expect": {"address": "100.64.0.1", "version": 4, "category": "shared", "name": "Shared Address Space", "block": "100.64.0.0/10", "rfc": "RFC 6598", "globallyReachable": false}},
  {"name": "100.128.0.1 is just past the /10, so global", "args": ["100.128.0.1"], "expect": {"address": "100.128.0.1", "version": 4, "category": "global", "name": "Global unicast", "block": null, "rfc": null, "globallyReachable": true}},
  {"name": "IPv4 link-local", "args": ["169.254.10.20"], "expect": {"address": "169.254.10.20", "version": 4, "category": "link-local", "name": "Link Local", "block": "169.254.0.0/16", "rfc": "RFC 3927", "globallyReachable": false}},
  {"name": "mDNS group is multicast", "args": ["224.0.0.251"], "expect": {"address": "224.0.0.251", "version": 4, "category": "multicast", "name": "Multicast", "block": "224.0.0.0/4", "rfc": "RFC 5771", "globallyReachable": null}},
  {"name": "SSDP group is multicast", "args": ["239.255.255.250"], "expect": {"address": "239.255.255.250", "version": 4, "category": "multicast", "name": "Multicast", "block": "224.0.0.0/4", "rfc": "RFC 5771", "globallyReachable": null}},
  {"name": "TEST-NET-1 documentation", "args": ["192.0.2.10"], "expect": {"address": "192.0.2.10", "version": 4, "category": "documentation", "name": "Documentation (TEST-NET-1)", "block": "192.0.2.0/24", "rfc": "RFC 5737", "globallyReachable": false}},
  {"name": "0.0.0.0 is the most specific /32, not this-network /8", "args": ["0.0.0.0"], "expect": {"address": "0.0.0.0", "version": 4, "category": "unspecified", "name": "This host on this network", "block": "0.0.0.0/32", "rfc": "RFC 1122", "globallyReachable": false}},
  {"name": "elsewhere in 0/8 is this network", "args": ["0.1.2.3"], "expect": {"address": "0.1.2.3", "version": 4, "category": "this-network", "name": "This network", "block": "0.0.0.0/8", "rfc": "RFC 791", "globallyReachable": false}},
  {"name": "PCP anycast /32 overrides its /24 and is globally reachable", "args": ["192.0.0.9"], "expect": {"address": "192.0.0.9", "version": 4, "category": "protocol", "name": "Port Control Protocol Anycast", "block": "192.0.0.9/32", "rfc": "RFC 7723", "globallyReachable": true}},
  {"name": "the rest of 192.0.0.0/24 is IETF protocol assignments", "args": ["192.0.0.100"], "expect": {"address": "192.0.0.100", "version": 4, "category": "protocol", "name": "IETF Protocol Assignments", "block": "192.0.0.0/24", "rfc": "RFC 6890", "globallyReachable": false}},
  {"name": "limited broadcast", "args": ["255.255.255.255"], "expect": {"address": "255.255.255.255", "version": 4, "category": "broadcast", "name": "Limited Broadcast", "block": "255.255.255.255/32", "rfc": "RFC 8190", "globallyReachable": false}},
  {"name": "class E reserved", "args": ["250.1.1.1"], "expect": {"address": "250.1.1.1", "version": 4, "category": "reserved", "name": "Reserved", "block": "240.0.0.0/4", "rfc": "RFC 1112", "globallyReachable": false}},
  {"name": "benchmarking /15 reaches 198.19.255.255", "args": ["198.19.255.255"], "expect": {"address": "198.19.255.255", "version": 4, "category": "benchmarking", "name": "Benchmarking", "block": "198.18.0.0/15", "rfc": "RFC 2544", "globallyReachable": false}},
  {"name": "a public resolver is global", "args": ["8.8.8.8"], "expect": {"address": "8.8.8.8", "version": 4, "category": "global", "name": "Global unicast", "block": null, "rfc": null, "globallyReachable": true}},
  {"name": "IPv6 loopback", "args": ["::1"], "expect": {"address": "::1", "version": 6, "category": "loopback", "name": "Loopback Address", "block": "::1/128", "rfc": "RFC 4291", "globallyReachable": false}},
  {"name": "IPv6 unspecified", "args": ["::"], "expect": {"address": "::", "version": 6, "category": "unspecified", "name": "Unspecified Address", "block": "::/128", "rfc": "RFC 4291", "globallyReachable": false}},
  {"name": "IPv6 link-local, returned canonical", "args": ["FE80::0001"], "expect": {"address": "fe80::1", "version": 6, "category": "link-local", "name": "Link-Local Unicast", "block": "fe80::/10", "rfc": "RFC 4291", "globallyReachable": false}},
  {"name": "unique local is private", "args": ["fd12:3456::1"], "expect": {"address": "fd12:3456::1", "version": 6, "category": "private", "name": "Unique-Local", "block": "fc00::/7", "rfc": "RFC 4193", "globallyReachable": false}},
  {"name": "IPv6 documentation", "args": ["2001:db8::1"], "expect": {"address": "2001:db8::1", "version": 6, "category": "documentation", "name": "Documentation", "block": "2001:db8::/32", "rfc": "RFC 3849", "globallyReachable": false}},
  {"name": "Teredo /32 is more specific than 2001::/23; reachability N/A", "args": ["2001:0:1::1"], "expect": {"address": "2001:0:1::1", "version": 6, "category": "translation", "name": "TEREDO", "block": "2001::/32", "rfc": "RFC 4380", "globallyReachable": null}},
  {"name": "PCP anycast /128", "args": ["2001:1::1"], "expect": {"address": "2001:1::1", "version": 6, "category": "protocol", "name": "Port Control Protocol Anycast", "block": "2001:1::1/128", "rfc": "RFC 7723", "globallyReachable": true}},
  {"name": "IPv4-mapped keeps its dotted tail", "args": ["::FFFF:192.168.1.1"], "expect": {"address": "::ffff:192.168.1.1", "version": 6, "category": "ipv4-mapped", "name": "IPv4-mapped Address", "block": "::ffff:0:0/96", "rfc": "RFC 4291", "globallyReachable": false}},
  {"name": "all-nodes multicast", "args": ["ff02::1"], "expect": {"address": "ff02::1", "version": 6, "category": "multicast", "name": "Multicast", "block": "ff00::/8", "rfc": "RFC 4291", "globallyReachable": null}},
  {"name": "NAT64 well-known prefix, canonical in hex", "args": ["64:ff9b::8.8.8.8"], "expect": {"address": "64:ff9b::808:808", "version": 6, "category": "translation", "name": "IPv4-IPv6 Translat.", "block": "64:ff9b::/96", "rfc": "RFC 6052", "globallyReachable": true}},
  {"name": "a public IPv6 address is global", "args": ["2606:4700::1111"], "expect": {"address": "2606:4700::1111", "version": 6, "category": "global", "name": "Global unicast", "block": null, "rfc": null, "globallyReachable": true}},
  {"name": "a host name is not an address", "args": ["localhost"], "expectError": "is not an IPv4 or IPv6 address"},
  {"name": "a block is not an address", "args": ["10.0.0.1/8"], "expectError": "is not an IPv4 or IPv6 address"},
  {"name": "a zone id is refused", "args": ["fe80::1%eth0"], "expectError": "is not an IPv4 or IPv6 address"},
  {"name": "a leading zero is refused", "args": ["010.0.0.1"], "expectError": "is not an IPv4 or IPv6 address"},
  {"name": "a trailing newline is refused", "args": ["127.0.0.1\n"], "expectError": "is not an IPv4 or IPv6 address"}
]