@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.
Files changed (43) hide show
  1. package/README.md +7 -7
  2. package/dist/chunks/{index-wm9ypkjq.js → index-22sbskdx.js} +13 -5
  3. package/dist/chunks/{server-n2q4tzy4.js → server-1ftkqkx5.js} +1 -1
  4. package/dist/cli/index.js +2990 -264
  5. package/dist/types/adapters/devices/catalog.d.ts +14 -0
  6. package/dist/types/adapters/devices/fortios/firewall.d.ts +21 -0
  7. package/dist/types/adapters/devices/fortios/index.d.ts +55 -0
  8. package/dist/types/adapters/devices/fortios/models.d.ts +14 -0
  9. package/dist/types/adapters/devices/fortios/names.d.ts +32 -0
  10. package/dist/types/adapters/devices/fortios/plan.d.ts +26 -0
  11. package/dist/types/adapters/devices/fortios/render.d.ts +36 -0
  12. package/dist/types/adapters/devices/fortios/routing.d.ts +32 -0
  13. package/dist/types/adapters/devices/fortios/tree.d.ts +33 -0
  14. package/dist/types/schema/common.d.ts +1 -1
  15. package/dist/types/schema/device.d.ts +1 -1
  16. package/dist/types/schema/firewall.d.ts +3 -3
  17. package/dist/types/schema/interfaces.d.ts +13 -13
  18. package/dist/types/schema/policy.d.ts +3 -3
  19. package/dist/types/schema/routing.d.ts +7 -7
  20. package/dist/types/schema/system.d.ts +7 -7
  21. package/package.json +5 -2
  22. package/src/adapters/devices/catalog.ts +2 -1
  23. package/src/adapters/devices/fortios/TRAPS.md +40 -0
  24. package/src/adapters/devices/fortios/firewall.ts +352 -0
  25. package/src/adapters/devices/fortios/index.ts +800 -0
  26. package/src/adapters/devices/fortios/models.ts +7 -0
  27. package/src/adapters/devices/fortios/names.ts +78 -0
  28. package/src/adapters/devices/fortios/plan.ts +840 -0
  29. package/src/adapters/devices/fortios/render.ts +734 -0
  30. package/src/adapters/devices/fortios/routing.ts +444 -0
  31. package/src/adapters/devices/fortios/tree.ts +121 -0
  32. package/src/adapters/devices/index.ts +2 -1
  33. package/src/adapters/devices/junos/TRAPS.md +2 -2
  34. package/src/adapters/devices/raisecom-ros/TRAPS.md +2 -2
  35. package/src/adapters/devices/routeros/TRAPS.md +5 -5
  36. package/src/adapters/devices/vrp/TRAPS.md +4 -4
  37. package/src/schema/common.ts +1 -1
  38. package/src/schema/device.ts +1 -1
  39. package/src/schema/firewall.ts +3 -3
  40. package/src/schema/interfaces.ts +13 -13
  41. package/src/schema/policy.ts +3 -3
  42. package/src/schema/routing.ts +7 -7
  43. package/src/schema/system.ts +7 -7
@@ -53,6 +53,20 @@ export declare const catalog: {
53
53
  };
54
54
  };
55
55
  };
56
+ readonly fortios: {
57
+ readonly "FG-3700D": {
58
+ readonly ports: {
59
+ readonly "40g": 4;
60
+ readonly "10g": 28;
61
+ readonly "1g": 2;
62
+ };
63
+ readonly spelling: {
64
+ readonly "40g": "port{n}";
65
+ readonly "10g": "port{n+4}";
66
+ readonly "1g": "mgmt{n}";
67
+ };
68
+ };
69
+ };
56
70
  };
57
71
  export type Catalog = typeof catalog;
58
72
  export type PlatformName = keyof Catalog;
@@ -0,0 +1,21 @@
1
+ import type { AclRule, Device, Family, FilterMatch, FilterRule, NatRule, Ports, Protocol } from "../../../schema";
2
+ import { Block } from "./tree";
3
+ /** IP protocol numbers, for a protocol the platform names only by number. */
4
+ export declare const PROTOCOL_NUMBER: Record<Protocol, number>;
5
+ /** NAT rules of both directions, which central NAT needs turned on. */
6
+ export declare function natRules(device: Device): NatRule<string, string>[];
7
+ /** Which families a rule applies to: its own, its addresses', or both. */
8
+ export declare function familiesOf(device: Device, match: FilterMatch<string, string> | undefined): Family[];
9
+ /** A port or ports as the platform writes them in a service: `22`, `1000-2000`. */
10
+ export declare function portList(ports: Ports | undefined): string[];
11
+ /** The service a rule matches, by name, with what it holds. `ALL` when the rule names no protocol and no port; ports without a protocol are TCP's and UDP's. */
12
+ export declare function serviceOf(match: FilterMatch<string, string> | undefined, family: Family): {
13
+ name: string;
14
+ block?: Block;
15
+ };
16
+ /** A rule the platform keeps without being told: replies to a session it let through, and packets that belong to one, pass on their own. */
17
+ export declare function isImplied(rule: FilterRule<string, string>): boolean;
18
+ /** Packet filtering, who reaches the device, NAT and stateless ACLs. */
19
+ export declare function firewall(root: Block, device: Device): void;
20
+ /** Whether a port's ACL drops before it accepts: an accept before a drop is an exception the platform's ACLs cannot hold. */
21
+ export declare function acceptsBeforeDrop(rules: readonly AclRule<string>[]): boolean;
@@ -0,0 +1,55 @@
1
+ import type { Client } from "ssh2";
2
+ import type { Device, Family } from "../../../schema";
3
+ import type { ApplyOptions, DeviceAdapter, Plan } from "../types";
4
+ /** What a session reads and writes: an SSH shell, or anything else that streams the CLI. */
5
+ export type Channel = {
6
+ write(data: string): unknown;
7
+ on(event: "data", listener: (chunk: Buffer) => void): unknown;
8
+ on(event: "close", listener: () => void): unknown;
9
+ removeListener(event: "data", listener: (chunk: Buffer) => void): unknown;
10
+ removeListener(event: "close", listener: () => void): unknown;
11
+ };
12
+ /** A CLI over a channel: one line at a time, and what the device printed until its prompt came back. */
13
+ export declare class Cli {
14
+ private readonly channel;
15
+ private readonly newline;
16
+ /** The prompt that ended the last answer, which shows where the session is: `(port1)` inside an entry. */
17
+ prompt: string;
18
+ constructor(channel: Channel, newline?: string);
19
+ /** Wait for the prompt, after logging in. */
20
+ ready(timeout?: number): Promise<void>;
21
+ /** Send one line and return what the device printed after it, without the echo or the prompt. */
22
+ run(line: string, timeout?: number): Promise<string>;
23
+ /** Answer a question the device asked. */
24
+ answer(reply: "y" | "n", timeout?: number): Promise<string>;
25
+ /** What the device prints until its prompt or a question. A session the device ended, or that went silent, fails. */
26
+ private collect;
27
+ }
28
+ export declare function login(device: Device): Promise<Client>;
29
+ /** Refuse a device on a release this adapter was not proved on, before anything is read or sent. */
30
+ export declare function checkVersion(cli: Cli, device: Device): Promise<void>;
31
+ /** Secrets the device prints: a password or an SNMPv3 key as a cipher, a certificate's key encrypted, and the SNMP community in clear. None leave the read. */
32
+ export declare function scrub(text: string): string;
33
+ /** Every section Circuit manages, as the device holds it, credentials scrubbed. */
34
+ export declare function readConfig(cli: Cli, device: Device): Promise<string>;
35
+ export declare function read(device: Device): Promise<string>;
36
+ /**
37
+ * A line with each secret's value in place, escaped inside its quotes. A certificate's key from a variable is PEM encoded as one line of base64, and is sent as the PEM it holds. A file saved with Windows line endings is sent with plain ones: the CLI takes each carriage return as a line of its own, and refuses the key, `Invalid private key`. A `?`, which the CLI takes as a call for help, is typed literally.
38
+ */
39
+ export declare function withSecrets(line: string): string;
40
+ /** How a change that could cut access is guarded: the device reloads its saved configuration after `seconds` unless `prove` shows access survived. */
41
+ export type Guard = {
42
+ seconds: number;
43
+ prove: () => Promise<void>;
44
+ };
45
+ /**
46
+ * Send a plan line by line, each applied as it arrives. The device is first set to revert what is not saved, so a refused line or a fresh login that fails reloads its saved configuration. Once access is proved the change is saved, and changes save themselves again.
47
+ */
48
+ export declare function configure(cli: Cli, plan: Plan, guard: Guard): Promise<void>;
49
+ export declare function apply(device: Device, _network: readonly Device[], plan: Plan, options: ApplyOptions): Promise<void>;
50
+ /** The lines that replace a prefix list's entries with what a registry returned: every entry is purged, then each prefix added, matching it and anything more specific. */
51
+ export declare function fillLines(set: string, family: Family, prefixes: string[]): string[];
52
+ /** Replace a prefix list `refresh` fetched. It cannot cut access, so it is sent without a guard, and saved as it goes. `purge` asks to confirm, and is answered yes. */
53
+ export declare function fill(device: Device, _network: readonly Device[], set: string, family: Family, prefixes: string[]): Promise<void>;
54
+ export declare function unsupported(device: Device): string[];
55
+ export declare const fortios: DeviceAdapter;
@@ -0,0 +1,14 @@
1
+ export declare const models: {
2
+ readonly "FG-3700D": {
3
+ readonly ports: {
4
+ readonly "40g": 4;
5
+ readonly "10g": 28;
6
+ readonly "1g": 2;
7
+ };
8
+ readonly spelling: {
9
+ readonly "40g": "port{n}";
10
+ readonly "10g": "port{n+4}";
11
+ readonly "1g": "mgmt{n}";
12
+ };
13
+ };
14
+ };
@@ -0,0 +1,32 @@
1
+ import type { Device, Family } from "../../../schema";
2
+ type Addressed = {
3
+ addresses?: readonly (string | {
4
+ address: string;
5
+ peer?: string;
6
+ })[];
7
+ vrf?: string;
8
+ lag?: string;
9
+ };
10
+ /** The name the platform gives a port or an interface: a port by its spelling, any other interface by its key. */
11
+ export declare function nameOf(device: Device, name: string): string;
12
+ /** A port's or an interface's settings, by its key. */
13
+ export declare function settingsOf(device: Device, name: string): Addressed | undefined;
14
+ /** Every address of a port or an interface. */
15
+ export declare function addressesOf(settings: Addressed | undefined): string[];
16
+ /** An address or prefix with its length, a bare address taken as a host. */
17
+ export declare const withLength: (value: string) => string;
18
+ /** The family of an address or prefix. */
19
+ export declare const familyOfPrefix: (value: string) => Family;
20
+ /** `192.0.2.0 255.255.255.0`, how the platform writes an IPv4 prefix. */
21
+ export declare const subnet: (prefix: string) => string;
22
+ /** The canonical form of a prefix: its network address and length, a bare address taken as a host. */
23
+ export declare const network: (prefix: string) => string;
24
+ /** The number of a VRF on the platform: its place among the device's VRFs, the default table being 0. */
25
+ export declare function vrfNumber(device: Device, vrf: string | undefined): number;
26
+ /** The interface whose own network holds an address, the most specific when several do, in one routing table. */
27
+ export declare function interfaceFor(device: Device, address: string, vrf?: string): string | undefined;
28
+ /** The interface that holds an address as its own. */
29
+ export declare function holderOf(device: Device, address: string): string | undefined;
30
+ /** Every port and interface with an address, by key, where the device's services answer. */
31
+ export declare function addressed(device: Device): string[];
32
+ export {};
@@ -0,0 +1,26 @@
1
+ import type { ApplyOptions, Plan } from "../types";
2
+ import { Block } from "./tree";
3
+ /** How the plan treats the entries of one table. */
4
+ type Table = {
5
+ /** Entries the factory holds. The plan neither reads nor removes them. */
6
+ factory?: readonly string[];
7
+ /** The device keeps the entries in an order of their own, which `move` changes. */
8
+ ordered?: true;
9
+ /** An entry is known by what it holds, not by its number. */
10
+ byContent?: true;
11
+ /** Settings the device gives an entry it creates. They are unset when the render does not hold them. */
12
+ created?: (entry: Block) => readonly string[];
13
+ /** Settings an entry keeps for life. A change deletes the entry and creates it again. */
14
+ fixed?: readonly string[];
15
+ };
16
+ /** Tables whose entries need more than a plain comparison, by section. */
17
+ export declare const TABLES: Record<string, Table>;
18
+ /** The configuration as the plan reads it: factory entries and the device's own settings left out. */
19
+ export declare function clean(text: string): string;
20
+ /**
21
+ * What changes, by section, in the order the render lists them. Entries that go are deleted after everything else, in the reverse order, so nothing is deleted while another section still names it.
22
+ *
23
+ * A secret is sent when its entry is new, or with `secrets` set; it cannot be read back to compare.
24
+ */
25
+ export declare function plan(desired: string, current: string, options: Pick<ApplyOptions, "secrets">): Plan;
26
+ export {};
@@ -0,0 +1,36 @@
1
+ import type { Device, Helper, Severity } from "../../../schema";
2
+ /** Where the pre-login banner's text is kept. */
3
+ export declare const BANNER = "system replacemsg admin \"pre_admin-disclaimer-text\"";
4
+ /** Every section Circuit manages, in the order a change goes in: what others name comes first. */
5
+ export declare const SECTIONS: readonly ["vpn certificate local", "vpn certificate ca", "system global", "system replacemsg admin \"pre_admin-disclaimer-text\"", "system settings", "system accprofile", "system admin", "system interface", "system gre-tunnel", "system vxlan", "system dns", "system dns-server", "system ntp", "system snmp sysinfo", "system snmp community", "system snmp user", "log memory setting", "log memory filter", "log disk setting", ...string[], "system sflow", "system netflow", "system dhcp server", "router static", "router static6", "router prefix-list", "router prefix-list6", "router community-list", "router route-map", "router ospf", "router ospf6", "router bgp", "system session-helper", "firewall address", "firewall address6", "firewall addrgrp", "firewall addrgrp6", "firewall service custom", "firewall ippool", "firewall vip", "firewall policy", "firewall policy6", "firewall local-in-policy", "firewall local-in-policy6", "firewall central-snat-map", "firewall acl", "firewall acl6"];
6
+ export type Section = (typeof SECTIONS)[number];
7
+ /** Sections `show` prints without what matters, which `show full-configuration` prints: a certificate's text. */
8
+ export declare const FULL: readonly string[];
9
+ /** The zone number for an IANA zone. UTC when the config names none. */
10
+ export declare function zoneOf(timezone?: string): string | undefined;
11
+ /** What each role may do: the factory profile for an admin, and a profile Circuit adds for the others. */
12
+ export declare const PROFILE: {
13
+ readonly admin: "super_admin";
14
+ readonly operator: "circuit-operator";
15
+ readonly "read-only": "circuit-read-only";
16
+ };
17
+ /** The most public keys a user holds. */
18
+ export declare const SSH_KEYS = 3;
19
+ /** The most resolvers the device and a DHCP server hold, per family. */
20
+ export declare const RESOLVERS: {
21
+ readonly device: 2;
22
+ readonly dhcp: 4;
23
+ };
24
+ /** The most syslog collectors the device sends to. */
25
+ export declare const COLLECTORS = 4;
26
+ /** The most VRFs the device holds besides its default table. */
27
+ export declare const VRFS = 31;
28
+ /** A severity as the platform names it. */
29
+ export declare const LEVEL: Record<Severity, string>;
30
+ /** The helpers the factory runs, by the name a config gives them: protocol and port of each. */
31
+ export declare const HELPERS: Partial<Record<Helper, readonly [string, number, number][]>>;
32
+ /** Speed by the platform's spelling, for each class a port's cage takes. */
33
+ export declare const SPEEDS: Record<string, Partial<Record<string, string>>>;
34
+ export declare function render(device: Device): string;
35
+ /** The one port or LAG that carries a VLAN tagged, which its VLAN interface sits on. `unsupported()` refuses any other case. */
36
+ export declare function vlanParent(device: Device, vlan: string): string | undefined;
@@ -0,0 +1,32 @@
1
+ import type { Device, Family, Neighbor, NeighborSettings, PolicyRule } from "../../../schema";
2
+ import { Block } from "./tree";
3
+ type AnyRule = PolicyRule<string, string>;
4
+ type AnyNeighbor = Neighbor<string, string>;
5
+ /** The route map a session takes when its config states none, so it learns or announces nothing. */
6
+ export declare const REJECT_ALL = "circuit-reject-all";
7
+ /** The start of the comment on a prefix list `refresh` fills. The plan keeps the entries the device holds in one. */
8
+ export declare const FILLED = "Filled by circuit refresh";
9
+ /** The table a prefix list of one family sits in. */
10
+ export declare const PREFIX_LIST: {
11
+ readonly ipv4: "router prefix-list";
12
+ readonly ipv6: "router prefix-list6";
13
+ };
14
+ /** The longest prefix of each family. */
15
+ export declare const BITS: {
16
+ readonly ipv4: 32;
17
+ readonly ipv6: 128;
18
+ };
19
+ /** A neighbor's settings with its group's beneath them. */
20
+ export declare function neighborSettings(device: Device, neighbor: AnyNeighbor): NeighborSettings<string>;
21
+ /** The families a session carries: its own, or the family of its address. */
22
+ export declare function familiesOfNeighbor(device: Device, neighbor: AnyNeighbor): Family[];
23
+ /** Whether OSPF or BGP detects a dead neighbor with BFD, which the device then runs. */
24
+ export declare function usesBfd(device: Device): boolean;
25
+ export declare function routing(root: Block, device: Device): void;
26
+ /** The family a rule is limited to, by its match: a family, a prefix, or a prefix set of one family. */
27
+ export declare function familyOfRule(device: Device, rule: AnyRule): Family | undefined;
28
+ /** A policy's rules with each call replaced by the rules it calls, in order. A called policy that decides nothing hands back to the caller. */
29
+ export declare function flatten(device: Device, policy: string, seen?: string[]): AnyRule[];
30
+ /** Routing the platform cannot express, or that this adapter does not yet write. */
31
+ export declare function routingGaps(device: Device): string[];
32
+ export {};
@@ -0,0 +1,33 @@
1
+ /** A setting the device prints as `unset <key>`, a key it holds empty on purpose, such as an ICMP service's type. */
2
+ export declare const UNSET = "\0unset";
3
+ /** One `edit` of a table: its name as written, and what it holds. */
4
+ export type Entry = {
5
+ id: string;
6
+ block: Block;
7
+ };
8
+ export declare class Block {
9
+ readonly settings: Map<string, string>;
10
+ readonly blocks: Map<string, Block>;
11
+ readonly entries: Map<string, Entry>;
12
+ /** Set a key. A value of several words is written as given. */
13
+ set(key: string, value: string | number): this;
14
+ /** The nested `config` block with this header, created when absent. */
15
+ block(header: string): Block;
16
+ /** The table entry with this name, created when absent. A name is quoted unless it is a number, or the table prints it bare, such as an OSPF area or an IPv6 prefix. */
17
+ entry(id: string | number, plain?: boolean): Block;
18
+ isEmpty(): boolean;
19
+ }
20
+ /** A string as the CLI takes it, in double quotes. */
21
+ export declare function quote(text: string): string;
22
+ /** Each of several strings quoted, as a list setting takes them. */
23
+ export declare const quoteAll: (texts: readonly string[]) => string;
24
+ /** A value's words; a quoted string is one word with its quotes. */
25
+ export declare function wordsOf(value: string): string[];
26
+ /** A word as the device means it, without quotes or escapes. */
27
+ export declare function bare(word: string): string;
28
+ /** The lines that build a block, at an indent, in the form `show` prints and the CLI takes. */
29
+ export declare function linesOf(block: Block, indent?: string): string[];
30
+ /** The whole configuration: each top-level block as `config <section>` to `end`. */
31
+ export declare function print(root: Block): string;
32
+ /** The tree of what `show` printed. Lines that are not configuration, such as the version header, are skipped. */
33
+ export declare function parse(text: string): Block;
@@ -7,7 +7,7 @@ export type Secret = {
7
7
  /** Name of the value in the environment or in `.env`. */
8
8
  readonly secret: string;
9
9
  } | {
10
- /** Path of a file holding the value, relative to the config file. */
10
+ /** Path of the file with the value, relative to the config file. */
11
11
  readonly secret_file: string;
12
12
  };
13
13
  /** An address without a length, IPv4 or IPv6, for example `10.0.0.1`. */
@@ -26,7 +26,7 @@ export type Vrf = {
26
26
  export type Device<Pl extends string = string, M extends string = string, N extends string = string, V extends string = string, I extends string = string, P extends string = string, S extends string = string, G extends string = string, A extends string = string, AS extends string = string, U extends string = string, F extends string = string, C extends string = string> = {
27
27
  /** Hostname. */
28
28
  name: string;
29
- /** Operating system, which decides the adapter that renders and applies the device. */
29
+ /** Operating system. It decides which adapter renders and applies the device. */
30
30
  platform: Pl;
31
31
  /** Hardware model. Decides which port names exist. */
32
32
  model: M;
@@ -12,7 +12,7 @@ export type PortRange = {
12
12
  export type Ports = number | PortRange | readonly (number | PortRange)[];
13
13
  /** A TCP header flag. */
14
14
  export type TcpFlag = "fin" | "syn" | "rst" | "psh" | "ack" | "urg";
15
- /** Conditions on a packet. All must hold. A rule with addresses of one family applies to that family only. */
15
+ /** Conditions on a packet. All must be true. A rule with addresses of one family applies to that family only. */
16
16
  export type FilterMatch<I extends string, AS extends string> = {
17
17
  /** Only packets of this family. */
18
18
  family?: Family;
@@ -50,7 +50,7 @@ export type FilterRule<I extends string, AS extends string> = {
50
50
  match?: FilterMatch<I, AS>;
51
51
  /** What happens to a matching packet. `reject` answers the sender, `drop` does not. */
52
52
  action: "accept" | "drop" | "reject";
53
- /** Hand the rest of an accepted flow to the fast path, past the remaining rules. */
53
+ /** Send the rest of an accepted flow through the fast path, skipping the remaining rules. */
54
54
  offload?: true;
55
55
  };
56
56
  /** Rules evaluated in order, first match wins, then `default`. */
@@ -117,7 +117,7 @@ export type AclRule<V extends string> = {
117
117
  src_port?: Ports;
118
118
  /** Destination port, or any of several. */
119
119
  dst_port?: Ports;
120
- /** Carried in this VLAN. */
120
+ /** In this VLAN. */
121
121
  vlan?: V;
122
122
  };
123
123
  /** What happens to a matching packet. */
@@ -1,7 +1,7 @@
1
1
  import type { Address, IP, Prefix, Secret } from "./common";
2
- /** A VLAN. The key it is declared under is its name. */
2
+ /** A VLAN. Its key in `vlans` is its name. */
3
3
  export type Vlan = {
4
- /** The number carried on the wire, 1 to 4094. */
4
+ /** The VLAN's number on the wire, 1 to 4094. */
5
5
  id: number;
6
6
  /** What the VLAN is for. */
7
7
  description?: string;
@@ -25,7 +25,7 @@ export type Vrrp = {
25
25
  /** Seconds between advertisements. 1 when absent. */
26
26
  interval?: number;
27
27
  };
28
- /** Layer 3 settings shared by every interface that can hold an address. */
28
+ /** Layer 3 settings shared by every interface that can have an address. */
29
29
  export type Routed<F extends string> = {
30
30
  /** Addresses with their length. Use `{ address, peer }` for a point-to-point address whose far end is outside its own prefix. */
31
31
  addresses?: readonly (Address | {
@@ -36,7 +36,7 @@ export type Routed<F extends string> = {
36
36
  ipv6_ra?: boolean;
37
37
  /** Overrides the device's `hardware_offload` for traffic routed through this interface. Software forwarding is what makes the firewall apply. */
38
38
  hardware_offload?: boolean;
39
- /** Virtual router addresses held on this interface. */
39
+ /** Virtual router addresses on this interface. */
40
40
  vrrp?: readonly Vrrp[];
41
41
  /** The VRF this interface routes in. The default table when absent. */
42
42
  vrf?: F;
@@ -63,11 +63,11 @@ export type PortStp = {
63
63
  };
64
64
  /** Layer 2 membership. A port or LAG with none of these is routed. */
65
65
  export type Switched<V extends string> = {
66
- /** Untagged member of one VLAN. */
66
+ /** The one VLAN this port or LAG is in, untagged. */
67
67
  access_vlan?: V;
68
- /** Tagged member of these VLANs. */
68
+ /** The VLANs this port or LAG carries, tagged. */
69
69
  trunk_vlans?: readonly V[];
70
- /** Untagged frames on a trunk belong to this VLAN. Only with `trunk_vlans`. */
70
+ /** Untagged frames on a trunk are in this VLAN. Only with `trunk_vlans`. */
71
71
  native_vlan?: V;
72
72
  /** Overrides the device's `stp` for this port. `false` stops it sending or acting on BPDUs. */
73
73
  stp?: boolean | PortStp;
@@ -97,7 +97,7 @@ export type Port<V extends string, A extends string, L extends string, F extends
97
97
  lldp?: boolean;
98
98
  /** Hardware ACL applied to traffic arriving on this port. */
99
99
  acl?: A;
100
- /** Member of this LAG. The LAG holds every other setting. */
100
+ /** The LAG this port is in. Every other setting goes on the LAG. */
101
101
  lag?: L;
102
102
  /** Another of our devices at the other end of the cable. */
103
103
  link?: Link;
@@ -112,19 +112,19 @@ type Base<F extends string> = Routed<F> & {
112
112
  /** A layer 3 interface on a VLAN. */
113
113
  export type VlanInterface<V extends string, F extends string> = Base<F> & {
114
114
  type: "vlan";
115
- /** The VLAN it sits on. */
115
+ /** The VLAN it is on. */
116
116
  vlan: V;
117
117
  };
118
- /** An interface that is always up and belongs to no link, for addresses that must not depend on one. */
118
+ /** An interface that is always up and is on no link, for addresses that must not depend on one. */
119
119
  export type Loopback<F extends string> = Base<F> & {
120
120
  type: "loopback";
121
121
  };
122
- /** A link aggregation. Member ports name it with `lag`. */
122
+ /** A link aggregation. Each member port points to it with `lag`. */
123
123
  export type Lag<V extends string, F extends string> = Base<F> & Switched<V> & {
124
124
  type: "lag";
125
- /** LACP negotiates membership with the far end; static bundles without asking. LACP when absent. */
125
+ /** LACP negotiates membership with the far end; `static` joins the ports without asking. LACP when absent. */
126
126
  mode?: "lacp" | "static";
127
- /** Number on platforms that name a LAG by number. Its position among the device's LAGs when absent. */
127
+ /** Number, on platforms where a LAG has a number instead of a name. Its position among the device's LAGs when absent. */
128
128
  id?: number;
129
129
  };
130
130
  /** A GRE tunnel. */
@@ -15,7 +15,7 @@ export type PrefixSet = {
15
15
  family: Family;
16
16
  };
17
17
  };
18
- /** Conditions on a route. All must hold. An empty match holds for every route. */
18
+ /** Conditions on a route. All must be true. An empty match is true for every route. */
19
19
  export type Match<S extends string> = {
20
20
  /** Only routes of this family. */
21
21
  family?: Family;
@@ -35,9 +35,9 @@ export type Match<S extends string> = {
35
35
  };
36
36
  /** The route's origin validation state. */
37
37
  rpki?: "valid" | "invalid" | "not-found";
38
- /** Carries this standard community, `asn:value`. */
38
+ /** Has this standard community, `asn:value`. */
39
39
  community?: string;
40
- /** Carries this large community, `asn:function:parameter`. */
40
+ /** Has this large community, `asn:function:parameter`. */
41
41
  large_community?: string;
42
42
  };
43
43
  /** Changes to a route. In community lists to remove, `*` stands for any value of a field, as in `64500:*:*`. */
@@ -1,5 +1,5 @@
1
1
  import type { Family, IP, Prefix, Secret } from "./common";
2
- /** A route the device carries without learning it. */
2
+ /** A route the device has without learning it. */
3
3
  export type StaticRoute<I extends string, F extends string> = {
4
4
  /** Destination. */
5
5
  prefix: Prefix;
@@ -11,7 +11,7 @@ export type StaticRoute<I extends string, F extends string> = {
11
11
  blackhole?: true;
12
12
  /** Preference against other routes to the same prefix. Lower wins. 1 when absent. */
13
13
  distance?: number;
14
- /** The VRF the route belongs to. The default table when absent. */
14
+ /** The VRF the route is in. The default table when absent. */
15
15
  vrf?: F;
16
16
  /** Why the route exists. */
17
17
  description?: string;
@@ -20,7 +20,7 @@ export type StaticRoute<I extends string, F extends string> = {
20
20
  * What a BGP neighbor is to us, with the roles RFC 9234 defines: `provider`, a transit we buy from; `customer`, one we sell transit to; `peer`, one we exchange our own routes with; `rs`, an exchange's route server; `rs-client`, a network using our route server.
21
21
  */
22
22
  export type BgpRole = "provider" | "customer" | "peer" | "rs" | "rs-client";
23
- /** Settings a BGP neighbor can state itself or take from its group. */
23
+ /** Settings a BGP neighbor can set itself or take from its group. */
24
24
  export type NeighborSettings<P extends string> = {
25
25
  /** The neighbor's AS. Our own AS makes the session internal. */
26
26
  remote_as?: number;
@@ -32,7 +32,7 @@ export type NeighborSettings<P extends string> = {
32
32
  import?: P;
33
33
  /** Policy for routes announced. Nothing is announced when absent. */
34
34
  export?: P;
35
- /** What the neighbor is to us, such as `provider` for a transit. Both sides then reject a route leak, after RFC 9234. */
35
+ /** What the neighbor is to us, such as `provider` for a transit. Both sides then reject a route leak, as RFC 9234 describes. */
36
36
  role?: BgpRole;
37
37
  /** The neighbor is more than one hop away. */
38
38
  multihop?: boolean;
@@ -51,11 +51,11 @@ export type NeighborSettings<P extends string> = {
51
51
  /** Detect a dead link in under a second with BFD. */
52
52
  bfd?: boolean;
53
53
  };
54
- /** One BGP session. Settings it does not state come from its group. */
54
+ /** One BGP session. Settings it does not set come from its group. */
55
55
  export type Neighbor<P extends string, G extends string> = NeighborSettings<P> & {
56
56
  /** The neighbor's address. */
57
57
  address: IP;
58
- /** Group whose settings this neighbor takes where it states none. */
58
+ /** The group this neighbor takes a setting from when it does not set that setting itself. */
59
59
  group?: NoInfer<G>;
60
60
  };
61
61
  /** BGP on this device. */
@@ -104,7 +104,7 @@ export type Ospf<I extends string> = {
104
104
  export type Routing<P extends string, G extends string, I extends string, F extends string> = {
105
105
  /** Identifies this router to its neighbors. */
106
106
  router_id?: IP;
107
- /** Routes the device carries without learning them. */
107
+ /** Routes the device has without learning them. */
108
108
  static?: readonly StaticRoute<I, F>[];
109
109
  /** BGP sessions and what they exchange. */
110
110
  bgp?: Bgp<P, G>;
@@ -12,7 +12,7 @@ export type System = {
12
12
  /** Answer queries from others. Off when absent. */
13
13
  serve?: boolean;
14
14
  };
15
- /** Time the device keeps. */
15
+ /** How the device keeps time. */
16
16
  ntp?: {
17
17
  /** Time sources, by address or name. */
18
18
  servers: readonly string[];
@@ -82,7 +82,7 @@ export type SnmpUser = {
82
82
  };
83
83
  /** How the device is reached and managed. */
84
84
  export type Management<I extends string, C extends string> = {
85
- /** Sources allowed to every service that does not state its own. */
85
+ /** Sources allowed to every service that does not set its own. */
86
86
  allow?: readonly Prefix[];
87
87
  /** Secure shell. */
88
88
  ssh?: Service & {
@@ -139,11 +139,11 @@ export type DhcpServer<I extends string> = {
139
139
  interface: I;
140
140
  /** The network it serves. */
141
141
  network: Prefix;
142
- /** Default gateway handed out. */
142
+ /** Default gateway given to clients. */
143
143
  gateway: IP;
144
- /** Resolvers handed out. */
144
+ /** Resolvers given to clients. */
145
145
  dns?: readonly IP[];
146
- /** First and last address handed out. */
146
+ /** First and last address given to clients. */
147
147
  pool: readonly [IP, IP];
148
148
  /** Seconds a lease lasts. */
149
149
  lease_time?: number;
@@ -164,9 +164,9 @@ export type DhcpRelay<I extends string> = {
164
164
  };
165
165
  /** A certificate the device presents or trusts. */
166
166
  export type Certificate = {
167
- /** The certificate, PEM. Public, so it lives in the repository. */
167
+ /** The certificate, PEM. Public, so it is kept in the repository. */
168
168
  certificate: string;
169
- /** Its private key: a PEM file through `secretFile`, or PEM base64-encoded as one line through `secret`. A certificate only trusted, such as a CA, has none. */
169
+ /** Its private key: a PEM file through `secretFile`, or PEM base64-encoded as one line through `secret`. A certificate the device only trusts, such as a CA, has none. */
170
170
  private_key?: Secret;
171
171
  };
172
172
  /** Export flow records or packet samples to collectors. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takodotid/circuit",
3
- "version": "0.25.0",
3
+ "version": "0.26.1",
4
4
  "description": "Declarative, vendor-neutral network configuration: describe each device in TypeScript, and Circuit makes the device match. Alpha.",
5
5
  "keywords": [
6
6
  "network",
@@ -15,7 +15,10 @@
15
15
  "huawei",
16
16
  "raisecom",
17
17
  "junos",
18
- "juniper"
18
+ "juniper",
19
+ "fortios",
20
+ "fortinet",
21
+ "fortigate"
19
22
  ],
20
23
  "homepage": "https://circuit.tako.id",
21
24
  "bugs": {
@@ -1,11 +1,12 @@
1
1
  // Every model each platform supports. Types read from here, so a model or port name that does not exist fails to compile.
2
2
 
3
+ import { models as fortios } from "./fortios/models";
3
4
  import { models as junos } from "./junos/models";
4
5
  import { models as raisecom } from "./raisecom-ros/models";
5
6
  import { models as routeros } from "./routeros/models";
6
7
  import { models as vrp } from "./vrp/models";
7
8
 
8
- export const catalog = { routeros, vrp, "raisecom-ros": raisecom, junos } as const;
9
+ export const catalog = { routeros, vrp, "raisecom-ros": raisecom, junos, fortios } as const;
9
10
 
10
11
  export type Catalog = typeof catalog;
11
12
  export type PlatformName = keyof Catalog;
@@ -0,0 +1,40 @@
1
+ # FortiOS traps
2
+
3
+ Behaviour that looks like something else. Each one has been hit on a FortiGate 3700D running FortiOS 6.2.2, without a licence.
4
+
5
+ - A change applies at `next` or `end`, and with `cfg-save automatic`, the factory setting, it is saved at once. `abort` discards the changes of the one object being edited, and only there: inside a table it is `Unknown action 0`, and the entries already left with `next` are applied.
6
+ - `cfg-save revert` keeps changes running but unsaved, and `cfg-revert-timeout` seconds after a change the device announces `System will reload` and reloads its saved configuration. The reload restarts the configuration, not the hardware, and takes about two minutes. `execute cfg reload` does the same at once, without asking, and says `no config to be reloaded` when nothing is unsaved. `execute cfg save` saves; setting `cfg-save automatic` again saves too.
7
+ - `cfg-save revert` set while saving is automatic is saved itself. After a reload the device is still in revert mode, and from then on every change made by hand is undone after the timeout until someone saves it or sets `cfg-save automatic`. Circuit sets it back at the end of every apply.
8
+ - `execute config-transaction start N` opens a candidate that `commit` applies and `abort` discards, but Circuit does not use it on 6.2.2. Inside one, deleting an entry does not release what its lists point to, so deleting a policy and then the address it used is refused: `The entry is used by other 1 entries`. A transaction whose session is cut off keeps every object it touched locked until its N minutes run out: `Can not config the object since it's being configured by another transaction`. Editing a `firewall policy6` entry after `unset central-nat` ends the session at `edit`. Deleting the user you are logged in as ends the session with `cmdb_txn_cache_data ... failed` and breaks every later transaction until the device restarts. `show` prints a new static route or policy with the comment of the last new one, which the commit corrects. OSPF's `config redistribute` is refused, `config child object 'redistribute' is not handled in transaction`, and a certificate added in one cannot be used by name until the commit. None of these happen outside a transaction.
9
+ - The CLI pages long output with `--More--`, and erases the prompt with spaces and a carriage return once it is answered.
10
+ - A `?` typed anywhere shows help at once and is never sent. Ctrl-V before it types it literally.
11
+ - The idle timeout, `admintimeout`, is 5 minutes by default; the session then returns to `login:`.
12
+ - With `pre-login-banner` on, the console shows the banner and waits on `(Press 'a' to accept):` before `login:`. Circuit answers `a`.
13
+ - `grep` after a pipe takes no `-E`, and a command ending in `| grep` reports `Command fail. Return code -27` after printing its matches.
14
+ - `show` prints a setting only when it differs from its default, and prints keys in its own order, not the order they were set. A new aggregate is given `device-identification enable` and `lldp-transmission enable`, a new VLAN interface `device-identification enable` and `role lan`, without being asked. Circuit unsets them.
15
+ - A port joins an aggregate only while nothing points to it, such as a static route, `entry not found in datasource`, and its speed cannot change while it is in one, not even back to `auto`: `Interface speed cannot be set for aggregated interfaces`. Circuit frees ports first: what points to a port that joins is deleted and created again after, a port whose speed changes leaves its aggregate and joins again, and an aggregate that goes, or is left with no port, goes before anything else with what points to it.
16
+ - `unset secondary-IP` hides the list of secondary addresses and drops it. NTP's `unset type` hides its servers but keeps them: `set type custom` brings them back. NTP refuses to delete its last server while `ntpsync` is on, and to empty the interfaces it serves on while `server-mode` is on, `There aren't any interfaces with NTP server enabled`; `unset server-mode` hides that list and lets go of the interfaces in it. The plan deletes a nested list before the setting that hides it, except `ntpsync`, which goes first.
17
+ - A DHCP server prints `dns-server1` only while `dns-service` is `specify`, the default, which `show` does not print. The factory server on `mgmt1` uses `default`, so the render writes `specify` before its resolvers.
18
+ - The timezone is a number of the platform's own, such as `53` for Jakarta, Bangkok and Hanoi. The default is `00`, Eniwetok, at UTC+12; UTC is `80`.
19
+ - Global `alias` is set again at every start, whatever was saved.
20
+ - `log memory setting` prints its `status` whether on or off, and `unset status` turns memory logging on.
21
+ - Two interfaces that are up cannot have overlapping subnets, `Subnets overlap between ...`, so an address moving from one to another must leave the first before it joins the second.
22
+ - A static route identical to another is refused, `Duplicated entry`. An IPv4 route's destination is not printed when it is the default route; neither is IPv6's.
23
+ - A deny policy is given `logtraffic disable`, and its action is not printed, since deny is the default. `send-deny-packet` exists only while a policy denies: set before `action deny` or unset after `action accept`, it is `command parse error`. So the render writes `action deny` before `send-deny-packet`, and a plan removes the settings that go before it sets the ones that come: `send-deny-packet` is unset while the policy still denies, and set only once it does.
24
+ - `show` prints `unset` in two places: an ICMP service's `unset icmptype`, and a prefix list rule's `unset ge` and `unset le` for a bound it does not have.
25
+ - An SNMPv3 user authenticates with MD5 or SHA1 only, and has no list of sources: only a community has hosts. Circuit decides who reaches every service with local-in policies instead.
26
+ - The console ignores a user's trusted hosts.
27
+ - A tunnel's interface takes an IPv4 address only as a host, with the far end in `remote-ip`: `set ip 10.0.0.1 255.255.255.252` on one is dropped without a word.
28
+ - A GRE or VXLAN tunnel creates an interface of its own, named after it, which goes when the tunnel goes. VXLAN has no local address: it leaves from the address of the interface it points to.
29
+ - A static route has no VRF of its own. It lands in the VRF of the interface it leaves through, as `get router info routing-table all` shows, so a blackhole route cannot go in a VRF. OSPF and BGP have no VRF setting.
30
+ - The stateless ACL, `firewall acl` and `acl6`, only drops: it has no action.
31
+ - A route map stops at the first rule that matches, with no way to go on to the next, and its rules permit unless told to deny.
32
+ - `show vpn certificate local` prints a certificate without its text or key. `show full-configuration` prints both, the key encrypted.
33
+ - The device answers a private key it cannot read with `Invalid private key, password may be required`, with no `Command fail`, and the session goes on. A key whose lines end in CR LF gets the same answer, because the CLI takes each CR as a line of its own. The certificate fails only at `end`: `Attribute 'private-key' MUST be set`.
34
+ - A GRE or VXLAN interface takes no flow sampler, and says so without `Command fail`: `Netflow sampler isn't supported on Tunnel interface..`, and the same for sFlow and for VXLAN.
35
+ - A port in an aggregate has no `icmp-send-redirect`, `command parse error`, and loses it when it joins one.
36
+ - `purge` empties a table after asking `(y/n)`.
37
+ - A loopback has no MTU of its own and runs no VRRP. An interface's name has at most 15 characters.
38
+ - There is no WireGuard and no RPKI, `command parse error`. A route map has no large community and a BGP neighbor no role: neither is among their settings. SNMPv3 offers no SHA256.
39
+ - `execute backup config flash <comment>` keeps a revision on the device, and `execute restore config flash <id>` restores one.
40
+ - The ports are `port1` to `port4` at 40G and `port5` to `port32` at 10G, then `mgmt1` and `mgmt2`. The factory dedicates both management ports to management and gives them addresses `192.168.1.99` and `192.168.2.99`.