@takodotid/circuit 0.25.0 → 0.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/chunks/{index-wm9ypkjq.js → index-22sbskdx.js} +13 -5
- package/dist/chunks/{server-n2q4tzy4.js → server-1ftkqkx5.js} +1 -1
- package/dist/cli/index.js +2990 -264
- package/dist/types/adapters/devices/catalog.d.ts +14 -0
- package/dist/types/adapters/devices/fortios/firewall.d.ts +21 -0
- package/dist/types/adapters/devices/fortios/index.d.ts +55 -0
- package/dist/types/adapters/devices/fortios/models.d.ts +14 -0
- package/dist/types/adapters/devices/fortios/names.d.ts +32 -0
- package/dist/types/adapters/devices/fortios/plan.d.ts +26 -0
- package/dist/types/adapters/devices/fortios/render.d.ts +36 -0
- package/dist/types/adapters/devices/fortios/routing.d.ts +32 -0
- package/dist/types/adapters/devices/fortios/tree.d.ts +33 -0
- package/dist/types/schema/common.d.ts +1 -1
- package/dist/types/schema/device.d.ts +1 -1
- package/dist/types/schema/firewall.d.ts +3 -3
- package/dist/types/schema/interfaces.d.ts +13 -13
- package/dist/types/schema/policy.d.ts +3 -3
- package/dist/types/schema/routing.d.ts +7 -7
- package/dist/types/schema/system.d.ts +7 -7
- package/package.json +5 -2
- package/src/adapters/devices/catalog.ts +2 -1
- package/src/adapters/devices/fortios/TRAPS.md +40 -0
- package/src/adapters/devices/fortios/firewall.ts +352 -0
- package/src/adapters/devices/fortios/index.ts +800 -0
- package/src/adapters/devices/fortios/models.ts +7 -0
- package/src/adapters/devices/fortios/names.ts +78 -0
- package/src/adapters/devices/fortios/plan.ts +840 -0
- package/src/adapters/devices/fortios/render.ts +734 -0
- package/src/adapters/devices/fortios/routing.ts +444 -0
- package/src/adapters/devices/fortios/tree.ts +121 -0
- package/src/adapters/devices/index.ts +2 -1
- package/src/adapters/devices/junos/TRAPS.md +2 -2
- package/src/adapters/devices/raisecom-ros/TRAPS.md +2 -2
- package/src/adapters/devices/routeros/TRAPS.md +5 -5
- package/src/adapters/devices/vrp/TRAPS.md +4 -4
- package/src/schema/common.ts +1 -1
- package/src/schema/device.ts +1 -1
- package/src/schema/firewall.ts +3 -3
- package/src/schema/interfaces.ts +13 -13
- package/src/schema/policy.ts +3 -3
- package/src/schema/routing.ts +7 -7
- package/src/schema/system.ts +7 -7
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Port counts per speed class, and how the platform spells a port. `{n}` is the position within the class; `{n+4}` shifts it, because the platform numbers every data port in one run. The out-of-band management ports are the `1g` class.
|
|
2
|
+
export const models = {
|
|
3
|
+
"FG-3700D": {
|
|
4
|
+
ports: { "40g": 4, "10g": 28, "1g": 2 },
|
|
5
|
+
spelling: { "40g": "port{n}", "10g": "port{n+4}", "1g": "mgmt{n}" },
|
|
6
|
+
},
|
|
7
|
+
} as const;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// How the platform names what the config names: ports and interfaces, prefixes, and the routing table an interface sits in.
|
|
2
|
+
|
|
3
|
+
import { contains, familyOf, host, netmask, network as networkOf, split } from "../../../core/addr";
|
|
4
|
+
import type { Device, Family } from "../../../schema";
|
|
5
|
+
import { spell } from "../catalog";
|
|
6
|
+
|
|
7
|
+
type Addressed = { addresses?: readonly (string | { address: string; peer?: string })[]; vrf?: string; lag?: string };
|
|
8
|
+
|
|
9
|
+
/** The name the platform gives a port or an interface: a port by its spelling, any other interface by its key. */
|
|
10
|
+
export function nameOf(device: Device, name: string): string {
|
|
11
|
+
if (device.interfaces && name in device.interfaces) return name;
|
|
12
|
+
return spell(device.platform, device.model, name);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** A port's or an interface's settings, by its key. */
|
|
16
|
+
export function settingsOf(device: Device, name: string): Addressed | undefined {
|
|
17
|
+
return (device.interfaces?.[name] ?? device.ports?.[name as keyof typeof device.ports]) as Addressed | undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Every address of a port or an interface. */
|
|
21
|
+
export function addressesOf(settings: Addressed | undefined): string[] {
|
|
22
|
+
return (settings?.addresses ?? []).map((entry) => (typeof entry === "string" ? entry : entry.address));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** An address or prefix with its length, a bare address taken as a host. */
|
|
26
|
+
export const withLength = (value: string) => (value.includes("/") ? value : `${value}/${familyOf(value) === "ipv4" ? 32 : 128}`);
|
|
27
|
+
|
|
28
|
+
/** The family of an address or prefix. */
|
|
29
|
+
export const familyOfPrefix = (value: string): Family => familyOf(split(withLength(value)).addr);
|
|
30
|
+
|
|
31
|
+
/** `192.0.2.0 255.255.255.0`, how the platform writes an IPv4 prefix. */
|
|
32
|
+
export const subnet = (prefix: string) => `${host(prefix)} ${netmask(split(prefix).len)}`;
|
|
33
|
+
|
|
34
|
+
/** The canonical form of a prefix: its network address and length, a bare address taken as a host. */
|
|
35
|
+
export const network = (prefix: string) => networkOf(withLength(prefix));
|
|
36
|
+
|
|
37
|
+
/** The number of a VRF on the platform: its place among the device's VRFs, the default table being 0. */
|
|
38
|
+
export function vrfNumber(device: Device, vrf: string | undefined): number {
|
|
39
|
+
return vrf ? Object.keys(device.vrfs ?? {}).indexOf(vrf) + 1 : 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Every port and interface that routes, by key, with its settings. A LAG member routes through its LAG. */
|
|
43
|
+
function routedHolders(device: Device): [string, Addressed][] {
|
|
44
|
+
const holders = [...Object.entries(device.ports ?? {}), ...Object.entries(device.interfaces ?? {})] as [
|
|
45
|
+
string,
|
|
46
|
+
Addressed | undefined,
|
|
47
|
+
][];
|
|
48
|
+
return holders.filter((holder): holder is [string, Addressed] => holder[1] !== undefined && !holder[1].lag);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The interface whose own network holds an address, the most specific when several do, in one routing table. */
|
|
52
|
+
export function interfaceFor(device: Device, address: string, vrf?: string): string | undefined {
|
|
53
|
+
let best: { name: string; length: number } | undefined;
|
|
54
|
+
|
|
55
|
+
for (const [name, settings] of routedHolders(device)) {
|
|
56
|
+
if ((settings.vrf ?? undefined) !== vrf) continue;
|
|
57
|
+
|
|
58
|
+
for (const own of addressesOf(settings)) {
|
|
59
|
+
const length = split(own).len;
|
|
60
|
+
const holds = familyOf(host(own)) === familyOf(address) && contains(network(own), address);
|
|
61
|
+
if (holds && length > (best?.length ?? -1)) best = { name, length };
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return best?.name;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The interface that holds an address as its own. */
|
|
69
|
+
export function holderOf(device: Device, address: string): string | undefined {
|
|
70
|
+
return routedHolders(device).find(([, settings]) => addressesOf(settings).some((own) => host(own) === address))?.[0];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Every port and interface with an address, by key, where the device's services answer. */
|
|
74
|
+
export function addressed(device: Device): string[] {
|
|
75
|
+
return routedHolders(device)
|
|
76
|
+
.filter(([, settings]) => addressesOf(settings).length > 0)
|
|
77
|
+
.map(([name]) => name);
|
|
78
|
+
}
|