Functional Weave
Code in TypeScript

Suites · network-tools

Network tools and inventory

Parse and classify IPv4 and IPv6 addresses, CIDR and subnet maths, ports, MAC addresses and host names, and a network inventory with device status.

14 capabilities (7 core, 7 optional) and 4 gaps, in build order. Put each line in the file that calls it, then fune build.

1. Addresses

Read, write and classify IP addresses strictly.

net.ipv4 core
Parses, formats and checks dotted-quad IPv4, refusing leading zeros, octal and short forms.
Parse, format and check dotted-quad IPv4 addresses, refusing leading zeros, octal, hex and short forms.
import { parseIpv4, formatIpv4, isIpv4 } from "#fune/net.ipv4@^1";
net.ipv6 core
Parses IPv6 and writes it in RFC 5952 canonical form.
Parse IPv6 addresses and write them in RFC 5952 canonical form: lower-case, zeros compressed, IPv4 embedded.
import { parseIpv6, formatIpv6, isIpv6 } from "#fune/net.ipv6@^1";
net.ip-classify core
Loopback, private, link-local, multicast, documentation, CGNAT or global.
Classify an IPv4 or IPv6 address as loopback, private, link-local, multicast, documentation, CGNAT or global.
import { classifyIp } from "#fune/net.ip-classify@^1";

2. Subnets

CIDR blocks and the hosts in them.

net.cidr core
Network, broadcast, first and last host, host count, netmask and membership of a CIDR block.
CIDR blocks: network, broadcast, first and last host, host count, netmask and prefix, and membership.
import { cidrInfo, cidrContains, isCidr, prefixToNetmask, netmaskToPrefix } from "#fune/net.cidr@^1";
net.cidr-hosts optional
Lists every usable host in an IPv4 block, refusing blocks over a limit.
List every usable host address in an IPv4 CIDR block, refusing blocks larger than a limit.
import { cidrHosts } from "#fune/net.cidr-hosts@^1";

3. Names, ports and hardware

Validate the other identifiers an inventory holds.

net.hostname-validate core
Checks a host name against RFC 1123/952 label rules and normalises it.
Check a host name against RFC 1123 and RFC 952 label rules and length limits, and normalise it.
import { validateHostname } from "#fune/net.hostname-validate@^1";
net.port core
Checks a port number and names its IANA service and range.
Check a TCP/UDP port number and name the IANA service registered on it, with its system/user/dynamic range.
import { isPort, portService } from "#fune/net.port@^1";
net.port-list optional
Parses "22,80,8000-8010" into port numbers.
Parse a port list such as 22,80,8000-8010 into port numbers, in order and without duplicates.
import { parsePortList } from "#fune/net.port-list@^1";
net.mac-address optional
Validates and normalises a MAC address in any common form.
Validate a MAC address in colon, hyphen, Cisco dot or bare form and normalise it, with multicast and local bits.
import { validateMacAddress } from "#fune/net.mac-address@^1";

4. Inventory and status

Keep a list of devices and say how each is doing.

net.device-validate core
Validates an inventory entry (name, host, ports, MAC, subnet), listing every problem.
Validate one network inventory entry: name, host, ports, optional MAC and subnet, with every problem listed.
import { validateDevice } from "#fune/net.device-validate@^1";
net.latency-summary optional
Loss, min/avg/max, p95 and jitter from probe results.
Summarise probe results: sent, received, loss, min/avg/max, p95 and jitter, in whole microseconds.
import { summariseLatency } from "#fune/net.latency-summary@^1";
net.device-status optional
Up, degraded or down from that summary and thresholds.
Classify a device as up, degraded or down from its latency summary and loss, p95 and jitter thresholds.
import { deviceStatus } from "#fune/net.device-status@^1";
collections.sort-by optional
Sorts device records by a column.
Stably sort records by one key, ascending or descending, with a total order across mixed types.
import { sortBy } from "#fune/collections.sort-by@^1";
collections.search-text optional
Filters device records by a search box.
Filter records by a case-insensitive substring match across named fields, in input order.
import { searchText } from "#fune/collections.search-text@^1";
  • probing Pinging, port scanning and SNMP polling: the network I/O itself is yours.

Gaps

What this kind of app usually needs that Functional Weave does not have yet: write these yourself, or use a service.

  • ipv6-subnets Describing IPv6 prefixes (network, range, size, host lists): net.cidr describes IPv4 blocks and only tests IPv6 membership.
  • dns DNS lookups (A, AAAA, PTR, MX records) and whois are network work, not in caps.
  • discovery Discovering devices on a network (ARP, mDNS, scans) and importing them.