SeenDevicetypeno test imports ittype SeenDevice = { readonly address: string; readonly mac: string; readonly interface: string };A device seen: its address, its hardware address and the interface it was seen on.
Discovery of devices on a network by what a machine already knows of it: the neighbor table (ip neigh) or the ARP table (arp -an) read as devices with an address and a hardware address, and the devices that no declaration expects. Nothing is scanned: a device that has not talked to this machine is not seen, and a discovered asset is only listed (0002-estate-governance FR-002).
import { parseNeighbors } from "./discovery.ts";
parseNeighbors("192.168.1.20 dev eth0 lladdr aa:bb:cc:dd:ee:ff REACHABLE")[0]?.mac; // "aa:bb:cc:dd:ee:ff"SeenDevicetypeno test imports ittype SeenDevice = { readonly address: string; readonly mac: string; readonly interface: string };A device seen: its address, its hardware address and the interface it was seen on.
parseNeighborsfunctionfunction parseNeighbors(text: string): readonly SeenDevice[]The devices of a neighbor table, in the form of ip neigh show (<address> dev <if> lladdr <mac> <state>) or arp -an (? (<address>) at <mac> [ether] on <if>); an entry with no hardware address (FAILED, INCOMPLETE), a broadcast or a multicast address is not a device, and a device is once, by its hardware address.
deviceIdOfconstconst deviceIdOf: (mac: string) => stringThe identity a discovered device gets: device- and its hardware address without the colons.
Declaredtypeno test imports ittype Declared = { readonly asset: string; readonly address?: string; readonly mac?: string };What an estate declares of a device the network may show: the address or the hardware address of an asset.
unexpectedDevicesfunctionfunction unexpectedDevices(declared: readonly Declared[], seen: readonly SeenDevice[]): { readonly unexpected: readonly SeenDevice[]; readonly unseen: readonly string[]; }The devices seen that no asset declares (by hardware address, or by address where no hardware address is declared), and the assets that declare an address or a hardware address and were not seen.