@takodotid/circuit 0.34.2 → 0.35.0
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 +13 -14
- package/dist/chunks/index-20kcjxjg.js +174 -0
- package/dist/chunks/index-2r4bbhac.js +977 -0
- package/dist/chunks/index-n7w3tg5y.js +149 -0
- package/dist/chunks/new-w3zys5y4.js +172 -0
- package/dist/chunks/server-gzsf5me5.js +259 -0
- package/dist/cli/index.js +11347 -9018
- package/dist/helpers/index.js +594 -0
- package/dist/index.js +9 -28
- package/dist/types/core/{addresses.d.ts → address-space.d.ts} +23 -7
- package/dist/types/core/address.d.ts +44 -0
- package/dist/types/core/cabling.d.ts +41 -0
- package/dist/types/core/cross-checks.d.ts +28 -0
- package/dist/types/core/define.d.ts +25 -3
- package/dist/types/core/project-files.d.ts +12 -0
- package/dist/types/core/schema-docs.d.ts +13 -4
- package/dist/types/core/secrets.d.ts +62 -21
- package/dist/types/core/{graph.d.ts → topology.d.ts} +32 -12
- package/dist/types/core/utils.d.ts +8 -0
- package/dist/types/core/validator.d.ts +19 -0
- package/dist/types/helpers/bgp.d.ts +97 -0
- package/dist/types/helpers/checks.d.ts +32 -0
- package/dist/types/helpers/exchange.d.ts +49 -0
- package/dist/types/helpers/filters.d.ts +51 -0
- package/dist/types/helpers/index.d.ts +10 -0
- package/dist/types/helpers/route-server.d.ts +52 -0
- package/dist/types/index.d.ts +5 -3
- package/dist/types/integrations/librenms.d.ts +60 -0
- package/dist/types/integrations/netbox.d.ts +89 -0
- package/dist/types/integrations/peeringdb.d.ts +24 -0
- package/dist/types/integrations/prometheus.d.ts +24 -0
- package/dist/types/integrations/registries.d.ts +8 -0
- package/dist/types/platforms/bgp-wait.d.ts +18 -0
- package/dist/types/platforms/catalog.d.ts +109 -0
- package/dist/types/platforms/derive.d.ts +17 -0
- package/dist/types/platforms/fortios/firewall.d.ts +45 -0
- package/dist/types/platforms/fortios/index.d.ts +134 -0
- package/dist/types/platforms/fortios/names.d.ts +52 -0
- package/dist/types/platforms/fortios/plan.d.ts +104 -0
- package/dist/types/platforms/fortios/render.d.ts +75 -0
- package/dist/types/platforms/fortios/routing.d.ts +56 -0
- package/dist/types/platforms/fortios/tree.d.ts +37 -0
- package/dist/types/platforms/index.d.ts +13 -0
- package/dist/types/platforms/junos/bgp.d.ts +44 -0
- package/dist/types/platforms/junos/index.d.ts +114 -0
- package/dist/types/platforms/junos/render.d.ts +154 -0
- package/dist/types/platforms/line-diff.d.ts +67 -0
- package/dist/types/platforms/platform.d.ts +120 -0
- package/dist/types/platforms/raisecom-ros/index.d.ts +71 -0
- package/dist/types/platforms/raisecom-ros/render.d.ts +41 -0
- package/dist/types/platforms/routeros/export.d.ts +59 -0
- package/dist/types/platforms/routeros/index.d.ts +96 -0
- package/dist/types/{adapters/devices → platforms}/routeros/models.d.ts +4 -0
- package/dist/types/platforms/routeros/plan.d.ts +54 -0
- package/dist/types/platforms/routeros/render.d.ts +240 -0
- package/dist/types/platforms/vrp/index.d.ts +83 -0
- package/dist/types/platforms/vrp/render.d.ts +96 -0
- package/dist/types/schema/common.d.ts +12 -6
- package/dist/types/schema/index.d.ts +1 -0
- package/dist/types/schema/interfaces.d.ts +14 -6
- package/dist/types/schema/policy.d.ts +18 -10
- package/dist/types/schema/routing.d.ts +14 -1
- package/dist/types/schema/system.d.ts +16 -6
- package/dist/types/schema/time-zones.d.ts +2 -0
- package/dist/types/transport/console.d.ts +79 -23
- package/dist/types/transport/path-check.d.ts +32 -0
- package/dist/types/transport/ssh.d.ts +17 -15
- package/package.json +17 -11
- package/src/cli/graph-format.ts +91 -0
- package/src/cli/index.ts +1074 -484
- package/src/cli/new.ts +208 -175
- package/src/cli/rename.ts +97 -91
- package/src/core/address-space.ts +320 -0
- package/src/core/address.ts +202 -0
- package/src/core/cabling.ts +154 -0
- package/src/core/cross-checks.ts +364 -0
- package/src/core/define.ts +26 -3
- package/src/core/project-files.ts +35 -0
- package/src/core/schema-docs.ts +138 -130
- package/src/core/secrets.ts +170 -76
- package/src/core/topology.ts +656 -0
- package/src/core/utils.ts +37 -0
- package/src/core/validator.ts +407 -0
- package/src/helpers/bgp.ts +301 -0
- package/src/helpers/checks.ts +178 -0
- package/src/helpers/exchange.ts +117 -0
- package/src/helpers/filters.ts +107 -0
- package/src/helpers/index.ts +12 -0
- package/src/helpers/route-server.ts +212 -0
- package/src/index.ts +6 -3
- package/src/integrations/librenms.ts +291 -0
- package/src/integrations/netbox.ts +620 -0
- package/src/integrations/peeringdb.ts +173 -0
- package/src/integrations/prometheus.ts +90 -0
- package/src/integrations/registries.ts +25 -0
- package/src/platforms/bgp-wait.ts +41 -0
- package/src/platforms/catalog.ts +69 -0
- package/src/platforms/derive.ts +117 -0
- package/src/{adapters/devices → platforms}/fortios/TRAPS.md +6 -0
- package/src/platforms/fortios/firewall.ts +377 -0
- package/src/platforms/fortios/index.ts +1060 -0
- package/src/platforms/fortios/names.ts +130 -0
- package/src/platforms/fortios/plan.ts +929 -0
- package/src/platforms/fortios/render.ts +779 -0
- package/src/platforms/fortios/routing.ts +476 -0
- package/src/platforms/fortios/tree.ts +129 -0
- package/src/platforms/index.ts +36 -0
- package/src/{adapters/devices → platforms}/junos/TRAPS.md +8 -0
- package/src/platforms/junos/bgp.ts +293 -0
- package/src/platforms/junos/index.ts +1006 -0
- package/src/platforms/junos/render.ts +967 -0
- package/src/platforms/line-diff.ts +244 -0
- package/src/platforms/platform.ts +122 -0
- package/src/platforms/raisecom-ros/TRAPS.md +40 -0
- package/src/platforms/raisecom-ros/index.ts +731 -0
- package/src/platforms/raisecom-ros/render.ts +328 -0
- package/src/{adapters/devices → platforms}/routeros/TRAPS.md +16 -2
- package/src/platforms/routeros/export.ts +342 -0
- package/src/platforms/routeros/index.ts +636 -0
- package/src/{adapters/devices → platforms}/routeros/models.ts +2 -0
- package/src/platforms/routeros/plan.ts +444 -0
- package/src/platforms/routeros/render.ts +1483 -0
- package/src/platforms/vrp/TRAPS.md +45 -0
- package/src/platforms/vrp/index.ts +652 -0
- package/src/platforms/vrp/render.ts +615 -0
- package/src/schema/common.ts +15 -6
- package/src/schema/index.ts +1 -0
- package/src/schema/interfaces.ts +15 -5
- package/src/schema/policy.ts +22 -10
- package/src/schema/routing.ts +16 -1
- package/src/schema/system.ts +16 -6
- package/src/schema/time-zones.ts +482 -0
- package/src/studio/data.ts +172 -168
- package/src/studio/git.ts +95 -90
- package/src/studio/public/app.js +161 -150
- package/src/studio/public/compare.js +219 -212
- package/src/studio/public/diff.js +77 -75
- package/src/studio/public/dom.js +118 -108
- package/src/studio/public/evaluate.js +584 -545
- package/src/studio/public/export.js +120 -118
- package/src/studio/public/graph.js +1343 -1266
- package/src/studio/public/net.js +115 -109
- package/src/studio/public/tables.js +1135 -1083
- package/src/studio/public/tools.js +561 -529
- package/src/studio/server.ts +202 -196
- package/src/transport/console.ts +363 -271
- package/src/transport/path-check.ts +91 -0
- package/src/transport/ssh.ts +98 -94
- package/templates/colocation/checks.ts +11 -6
- package/templates/colocation/edge-01.ts +9 -9
- package/templates/colocation/routing.ts +2 -2
- package/templates/colocation/tenancy.ts +3 -3
- package/templates/colocation/tor-01.ts +3 -3
- package/templates/edge-router/checks.ts +4 -4
- package/templates/edge-router/edge-01.ts +5 -5
- package/templates/edge-router/routing.ts +2 -2
- package/templates/project/AGENTS.md +5 -1
- package/templates/single-site/checks.ts +2 -2
- package/dist/chunks/index-47debt16.js +0 -956
- package/dist/chunks/index-v8zgr7wm.js +0 -128
- package/dist/chunks/new-ny89s7y7.js +0 -166
- package/dist/chunks/server-tjbb3rqc.js +0 -251
- package/dist/presets/index.js +0 -394
- package/dist/types/adapters/devices/catalog.d.ts +0 -86
- package/dist/types/adapters/devices/derive.d.ts +0 -7
- package/dist/types/adapters/devices/fortios/firewall.d.ts +0 -23
- package/dist/types/adapters/devices/fortios/index.d.ts +0 -58
- package/dist/types/adapters/devices/fortios/names.d.ts +0 -48
- package/dist/types/adapters/devices/fortios/plan.d.ts +0 -28
- package/dist/types/adapters/devices/fortios/render.d.ts +0 -38
- package/dist/types/adapters/devices/fortios/routing.d.ts +0 -32
- package/dist/types/adapters/devices/fortios/tree.d.ts +0 -33
- package/dist/types/adapters/devices/index.d.ts +0 -3
- package/dist/types/adapters/devices/junos/bgp.d.ts +0 -11
- package/dist/types/adapters/devices/junos/index.d.ts +0 -42
- package/dist/types/adapters/devices/junos/render.d.ts +0 -52
- package/dist/types/adapters/devices/lines.d.ts +0 -56
- package/dist/types/adapters/devices/raisecom-ros/index.d.ts +0 -28
- package/dist/types/adapters/devices/routeros/export.d.ts +0 -39
- package/dist/types/adapters/devices/routeros/index.d.ts +0 -30
- package/dist/types/adapters/devices/routeros/plan.d.ts +0 -4
- package/dist/types/adapters/devices/routeros/render.d.ts +0 -100
- package/dist/types/adapters/devices/types.d.ts +0 -40
- package/dist/types/adapters/devices/vrp/index.d.ts +0 -27
- package/dist/types/adapters/registries/index.d.ts +0 -3
- package/dist/types/adapters/registries/librenms.d.ts +0 -15
- package/dist/types/adapters/registries/peeringdb.d.ts +0 -16
- package/dist/types/adapters/registries/prometheus.d.ts +0 -16
- package/dist/types/core/across.d.ts +0 -4
- package/dist/types/core/addr.d.ts +0 -34
- package/dist/types/core/files.d.ts +0 -6
- package/dist/types/core/merge.d.ts +0 -4
- package/dist/types/core/time.d.ts +0 -2
- package/dist/types/core/validate.d.ts +0 -2
- package/dist/types/presets/index.d.ts +0 -183
- package/src/adapters/devices/catalog.ts +0 -41
- package/src/adapters/devices/derive.ts +0 -59
- package/src/adapters/devices/fortios/firewall.ts +0 -362
- package/src/adapters/devices/fortios/index.ts +0 -923
- package/src/adapters/devices/fortios/names.ts +0 -115
- package/src/adapters/devices/fortios/plan.ts +0 -888
- package/src/adapters/devices/fortios/render.ts +0 -768
- package/src/adapters/devices/fortios/routing.ts +0 -444
- package/src/adapters/devices/fortios/tree.ts +0 -121
- package/src/adapters/devices/index.ts +0 -9
- package/src/adapters/devices/junos/bgp.ts +0 -269
- package/src/adapters/devices/junos/index.ts +0 -862
- package/src/adapters/devices/junos/render.ts +0 -872
- package/src/adapters/devices/lines.ts +0 -212
- package/src/adapters/devices/raisecom-ros/TRAPS.md +0 -25
- package/src/adapters/devices/raisecom-ros/index.ts +0 -693
- package/src/adapters/devices/routeros/export.ts +0 -321
- package/src/adapters/devices/routeros/index.ts +0 -346
- package/src/adapters/devices/routeros/plan.ts +0 -398
- package/src/adapters/devices/routeros/render.ts +0 -1490
- package/src/adapters/devices/types.ts +0 -38
- package/src/adapters/devices/vrp/TRAPS.md +0 -26
- package/src/adapters/devices/vrp/index.ts +0 -865
- package/src/adapters/registries/index.ts +0 -19
- package/src/adapters/registries/librenms.ts +0 -92
- package/src/adapters/registries/peeringdb.ts +0 -169
- package/src/adapters/registries/prometheus.ts +0 -71
- package/src/cli/graph.ts +0 -89
- package/src/core/across.ts +0 -350
- package/src/core/addr.ts +0 -174
- package/src/core/addresses.ts +0 -316
- package/src/core/files.ts +0 -32
- package/src/core/graph.ts +0 -640
- package/src/core/merge.ts +0 -19
- package/src/core/time.ts +0 -15
- package/src/core/validate.ts +0 -348
- package/src/presets/index.ts +0 -579
- /package/dist/types/{adapters/devices → platforms}/fortios/models.d.ts +0 -0
- /package/dist/types/{adapters/devices → platforms}/junos/models.d.ts +0 -0
- /package/dist/types/{adapters/devices → platforms}/raisecom-ros/models.d.ts +0 -0
- /package/dist/types/{adapters/devices → platforms}/vrp/models.d.ts +0 -0
- /package/src/{adapters/devices → platforms}/fortios/models.ts +0 -0
- /package/src/{adapters/devices → platforms}/junos/models.ts +0 -0
- /package/src/{adapters/devices → platforms}/raisecom-ros/models.ts +0 -0
- /package/src/{adapters/devices → platforms}/vrp/models.ts +0 -0
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { Family } from "../schema";
|
|
2
|
-
export declare const familyOf: (address: string) => Family;
|
|
3
|
-
/** An address as a number, or null when it is not one. */
|
|
4
|
-
export declare function parse(address: string): bigint | null;
|
|
5
|
-
/** `10.0.0.1/24` to its parts. Throws when it is not an address with a length. */
|
|
6
|
-
export declare function split(cidr: string): {
|
|
7
|
-
addr: string;
|
|
8
|
-
len: number;
|
|
9
|
-
family: Family;
|
|
10
|
-
};
|
|
11
|
-
export declare const isAddress: (text: string) => boolean;
|
|
12
|
-
export declare function isCidr(text: string): boolean;
|
|
13
|
-
/** `10.0.0.1/24` to `10.0.0.0/24`. */
|
|
14
|
-
export declare function network(cidr: string): string;
|
|
15
|
-
/** Is the address or prefix `inner` inside `outer`? */
|
|
16
|
-
export declare function contains(outer: string, inner: string): boolean;
|
|
17
|
-
/** A number back to the address it stands for. */
|
|
18
|
-
export declare const formatAddress: (value: bigint, family: Family) => string;
|
|
19
|
-
/** The first and last address of a prefix, as numbers. */
|
|
20
|
-
export declare function rangeOf(cidr: string): {
|
|
21
|
-
first: bigint;
|
|
22
|
-
last: bigint;
|
|
23
|
-
family: Family;
|
|
24
|
-
};
|
|
25
|
-
/** The fewest prefixes that cover every address from `first` to `last` and nothing else. */
|
|
26
|
-
export declare function prefixesBetween(first: bigint, last: bigint, family: Family): string[];
|
|
27
|
-
/** `/25` to `255.255.255.128`. */
|
|
28
|
-
export declare const netmask: (length: number) => string;
|
|
29
|
-
/** `/24` to `0.0.0.255`, the inverted mask some ACLs take. */
|
|
30
|
-
export declare const wildcard: (length: number) => string;
|
|
31
|
-
/** The address with its length dropped. */
|
|
32
|
-
export declare const host: (cidr: string) => string;
|
|
33
|
-
/** Whether another network can reach the address. IPv6 is global only inside 2000::/3, less documentation space. */
|
|
34
|
-
export declare function isGlobal(address: string): boolean;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/** Every TypeScript file of the project, relative to its root, in name order. */
|
|
2
|
-
export declare function projectSources(root: string, directory?: string): string[];
|
|
3
|
-
/** Whether a file's text declares the device: it calls defineDevice and gives it the name, written out whole. */
|
|
4
|
-
export declare function declaresDevice(text: string, name: string): boolean;
|
|
5
|
-
/** The project files that declare the device, relative to the root. */
|
|
6
|
-
export declare function deviceFiles(root: string, name: string, sources?: string[]): string[];
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
type Merged<T extends readonly object[]> = T extends readonly [infer Head, ...infer Tail extends readonly object[]] ? Head & Merged<Tail> : unknown;
|
|
2
|
-
/** Combine records into one. Unlike spreading them, a name two of them hold is an error rather than one silently replacing the other. */
|
|
3
|
-
export declare function merge<const T extends readonly Record<string, unknown>[]>(...records: T): Merged<T>;
|
|
4
|
-
export {};
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import type { Check, Community } from "../core/define";
|
|
2
|
-
import type { AclRule, Device, FilterRule, IP, PolicyRule, Port, Prefix } from "../schema";
|
|
3
|
-
/** IPv4 sources that never arrive from the internet: loopback, link-local and "this network", after RFC 6890. */
|
|
4
|
-
export declare const MARTIANS: readonly ["127.0.0.0/8", "169.254.0.0/16", "0.0.0.0/8"];
|
|
5
|
-
/** IPv4 private space, RFC 1918. */
|
|
6
|
-
export declare const PRIVATE_RANGES: readonly ["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"];
|
|
7
|
-
/** Hardware ACL rules dropping traffic arriving on a VLAN from sources that cannot be there: your own space, martians, private ranges. One rule per source. */
|
|
8
|
-
export declare const antiSpoofing: <V extends string>(vlan: V, sources: readonly Prefix[]) => AclRule<V>[];
|
|
9
|
-
/** UDP ports of services that answer a small request with a much larger reply, which attackers use to reflect floods at a victim. A reflected flood arrives from these ports. */
|
|
10
|
-
export declare const AMPLIFIERS: {
|
|
11
|
-
readonly qotd: 17;
|
|
12
|
-
readonly chargen: 19;
|
|
13
|
-
readonly dns: 53;
|
|
14
|
-
readonly portmap: 111;
|
|
15
|
-
readonly ntp: 123;
|
|
16
|
-
readonly netbios: 137;
|
|
17
|
-
readonly snmp: 161;
|
|
18
|
-
readonly cldap: 389;
|
|
19
|
-
readonly slp: 427;
|
|
20
|
-
readonly rip: 520;
|
|
21
|
-
readonly "ms-sql": 1434;
|
|
22
|
-
readonly ssdp: 1900;
|
|
23
|
-
readonly ard: 3283;
|
|
24
|
-
readonly "ws-discovery": 3702;
|
|
25
|
-
readonly mdns: 5353;
|
|
26
|
-
readonly coap: 5683;
|
|
27
|
-
readonly ubiquiti: 10001;
|
|
28
|
-
readonly memcached: 11211;
|
|
29
|
-
readonly dvr: 37810;
|
|
30
|
-
};
|
|
31
|
-
/** What `antiAmplification` leaves alone. */
|
|
32
|
-
export type AntiAmplificationOptions = {
|
|
33
|
-
/** Prefixes inside the destinations whose UDP fragments pass: for a host that receives UDP too large for one packet, such as SIP or some VPNs. Every fragment after the first is dropped when absent. */
|
|
34
|
-
keep_fragments?: readonly Prefix[];
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Hardware ACL rules dropping reflected UDP floods toward `destinations`, in the switch chip, without limiting anything else.
|
|
38
|
-
*
|
|
39
|
-
* - Replies from an amplifier no host asks across the internet are dropped.
|
|
40
|
-
* - Replies from DNS, NTP and SNMP are dropped only toward a port below 1024 that is not the service's own. A host that runs its own resolver, time server or monitoring keeps its answers. The service's own port passes first, so every drop takes the one range 0 to 1023: a switch chip has few port-range checkers, and on RouterOS a rule past them is invalid with every rule after it.
|
|
41
|
-
* - The fragments after the first carry no port, and a switch chip reads them as port 0. They are dropped, but toward `keep_fragments`.
|
|
42
|
-
*/
|
|
43
|
-
export declare function antiAmplification(destinations: readonly Prefix[], options?: AntiAmplificationOptions): AclRule<never>[];
|
|
44
|
-
/** Firewall rules dropping packets with a TCP flag combination no legitimate packet carries, for a forward chain. */
|
|
45
|
-
export declare const badTcpFlags: () => FilterRule<never, never>[];
|
|
46
|
-
/** The prefix lengths a BGP import accepts. */
|
|
47
|
-
export type SanityLengths = {
|
|
48
|
-
/** Shortest and longest IPv4 prefix accepted. /8 to /24 when absent. */
|
|
49
|
-
ipv4?: {
|
|
50
|
-
min: number;
|
|
51
|
-
max: number;
|
|
52
|
-
};
|
|
53
|
-
/** Shortest and longest IPv6 prefix accepted. /16 to /48 when absent. */
|
|
54
|
-
ipv6?: {
|
|
55
|
-
min: number;
|
|
56
|
-
max: number;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
/** Route policy rules rejecting what no neighbor should send: prefixes too short or too long for the global table, and RPKI invalid. Place it first in an import, or as a policy other imports call. */
|
|
60
|
-
export declare function bgpSanity(lengths?: SanityLengths): PolicyRule<never, never>[];
|
|
61
|
-
/** Each BGP neighbor's own policies and role, or its group's. */
|
|
62
|
-
export declare function neighborPolicies(device: Device): {
|
|
63
|
-
name: string;
|
|
64
|
-
address: string;
|
|
65
|
-
role: import("..").BgpRole | undefined;
|
|
66
|
-
import: string | undefined;
|
|
67
|
-
export: string | undefined;
|
|
68
|
-
}[];
|
|
69
|
-
/** The prefixes an export policy accepts by name. */
|
|
70
|
-
export declare function offered(device: Device, policy: string | undefined): string[];
|
|
71
|
-
/**
|
|
72
|
-
* Every BGP export ends in a reject that matches everything, so nothing leaves by accident. An export to a neighbor whose `role` is `customer` is left out: sending a customer everything you know is what it pays for, and cannot leak a route to the rest of the internet.
|
|
73
|
-
*/
|
|
74
|
-
export declare const exportsEndInReject: Check;
|
|
75
|
-
/** The VLANs a port carries, untagged or tagged. */
|
|
76
|
-
export declare const vlansOf: (port: {
|
|
77
|
-
access_vlan?: string;
|
|
78
|
-
trunk_vlans?: readonly string[];
|
|
79
|
-
}) => string[];
|
|
80
|
-
/** Where traffic from outside, before anything filters it, may go. Every VLAN not listed as untrusted is trusted, so a VLAN added later is protected without being listed. */
|
|
81
|
-
export type TrustBoundary = {
|
|
82
|
-
/** VLANs carrying traffic straight from outside: transits, exchanges, an ISP handoff. */
|
|
83
|
-
untrusted: readonly string[];
|
|
84
|
-
/** The devices that filter: the only ones that may give an untrusted VLAN an address, and the only ones a port carrying both kinds may face. */
|
|
85
|
-
routers: readonly string[];
|
|
86
|
-
/**
|
|
87
|
-
* Links between two switches that may carry both kinds, each named by its two devices: a site's switch extended to another building, with an exchange's VLAN and its own management on one cable. Neither end gives an untrusted VLAN an address.
|
|
88
|
-
*/
|
|
89
|
-
extended?: readonly (readonly [string, string])[];
|
|
90
|
-
};
|
|
91
|
-
/** A check: traffic from outside reaches your own VLANs only through a router. A port or LAG carrying an untrusted VLAN beside any other is on a router or faces one, and only a router gives an untrusted VLAN an address. */
|
|
92
|
-
export declare const trustBoundary: (boundary: TrustBoundary) => Check;
|
|
93
|
-
/** A GRE or VXLAN tunnel's local address is outside what the neighbors over it are offered, or their replies route back into the tunnel. */
|
|
94
|
-
export declare const tunnelsOutsideOffered: Check;
|
|
95
|
-
/**
|
|
96
|
-
* A BGP community scheme of large communities, `asn:function:parameter`, in the style of RFC 8195. Each field names the function number your network uses for it; leave out what your network does not offer.
|
|
97
|
-
*/
|
|
98
|
-
export type CommunityScheme<Class extends string = string> = {
|
|
99
|
-
/** Your AS. It is the first part of every community. */
|
|
100
|
-
asn: number;
|
|
101
|
-
/** Set on import: the kind of neighbor a route came from, `asn:function:class`. */
|
|
102
|
-
learned_from?: {
|
|
103
|
-
function: number;
|
|
104
|
-
classes: Readonly<Record<Class, number>>;
|
|
105
|
-
};
|
|
106
|
-
/** Set on import: the site a route was learned at, `asn:function:site`. `sites` names the sites, for the catalogue. */
|
|
107
|
-
learned_at?: {
|
|
108
|
-
function: number;
|
|
109
|
-
sites?: Readonly<Record<number, string>>;
|
|
110
|
-
};
|
|
111
|
-
/** Set on import: the AS a route was learned from, `asn:function:asn`. */
|
|
112
|
-
learned_from_as?: number;
|
|
113
|
-
/** A neighbor asks: do not announce the route to an AS, `asn:function:asn`, or to anyone, `asn:function:0`. */
|
|
114
|
-
do_not_announce?: number;
|
|
115
|
-
/** A neighbor asks: prepend toward an AS once, twice or three times, `asn:function:asn`. */
|
|
116
|
-
prepend?: {
|
|
117
|
-
once?: number;
|
|
118
|
-
twice?: number;
|
|
119
|
-
three_times?: number;
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* A neighbor asks: drop all traffic to this route, `asn:function:0`, usually one address under attack. Your router drops it, and so does every upstream in `upstreams`.
|
|
123
|
-
*
|
|
124
|
-
* `upstreams` maps an upstream's AS to its own blackhole community, as its NOC gives it. The route is passed to that upstream with it, so the traffic stops before it reaches your links. An upstream not listed never receives the route.
|
|
125
|
-
*/
|
|
126
|
-
blackhole?: {
|
|
127
|
-
function: number;
|
|
128
|
-
upstreams?: Readonly<Record<number, string>>;
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Policy rules and a catalogue from one community scheme, so the communities your routers set, the ones they act on, and the ones you publish never disagree.
|
|
133
|
-
*
|
|
134
|
-
* - `tag(neighborClass, neighborAs, { site, trusted })`: a rule for an import policy. It removes your communities a neighbor set, then adds where the route was learned. A `trusted` neighbor keeps its requests: do not announce, prepend, blackhole. `site` is needed when the scheme has `learned_at`.
|
|
135
|
-
* - `actions(neighborAs, { blackhole })`: rules for an export policy toward one neighbor. They act on a customer's action communities, then remove all of yours. Place them before the rules that accept. A blackholed route goes no further, unless `blackhole` names the neighbor's own blackhole community: then it is passed on with it, so the neighbor drops the traffic too.
|
|
136
|
-
* - `blackhole(prefixSets)`: rules for the import policy of a neighbor you trust with blackholes, before anything that rejects long prefixes. They take a route the neighbor asked to blackhole, but only inside `prefixSets`, its own space, and drop traffic to it here. One rule per set, so one call covers both families.
|
|
137
|
-
* - `catalogue`: every community, for `communities` in `defineNetwork`.
|
|
138
|
-
*/
|
|
139
|
-
export declare function communityScheme<const Class extends string>(scheme: CommunityScheme<Class>): {
|
|
140
|
-
community: (fn: number, parameter: number | string) => string;
|
|
141
|
-
tag: (neighborClass: Class, neighborAs: number, options?: {
|
|
142
|
-
site?: number;
|
|
143
|
-
trusted?: boolean;
|
|
144
|
-
}) => PolicyRule<never, never>;
|
|
145
|
-
actions: (neighborAs: number) => PolicyRule<never, never>[];
|
|
146
|
-
blackhole: <S extends string>(prefixSets: readonly S[]) => PolicyRule<never, S>[];
|
|
147
|
-
catalogue: Community[];
|
|
148
|
-
};
|
|
149
|
-
/** A member of an internet exchange: a network with a port on the fabric and an address on the peering LAN. */
|
|
150
|
-
export type ExchangeMember = {
|
|
151
|
-
/** Lowercase, and never reused. */
|
|
152
|
-
name: string;
|
|
153
|
-
asn: number;
|
|
154
|
-
/** The member's port on each fabric switch, by switch name. */
|
|
155
|
-
ports: Readonly<Record<string, string>>;
|
|
156
|
-
/** Its addresses on the peering LAN. The route servers peer with these. */
|
|
157
|
-
ipv4?: IP;
|
|
158
|
-
ipv6?: IP;
|
|
159
|
-
};
|
|
160
|
-
/** An internet exchange's peering LAN, as its fabric carries it. */
|
|
161
|
-
export type InternetExchange<V extends string> = {
|
|
162
|
-
/** The peering VLAN, by the name the fabric switches give it. */
|
|
163
|
-
vlan: V;
|
|
164
|
-
/** The peering LAN's subnets. */
|
|
165
|
-
lan: {
|
|
166
|
-
ipv4?: Prefix;
|
|
167
|
-
ipv6?: Prefix;
|
|
168
|
-
};
|
|
169
|
-
/** Addresses on the peering LAN no member may take, such as the route servers'. */
|
|
170
|
-
reserved?: readonly IP[];
|
|
171
|
-
/** How much broadcast, multicast and unknown unicast a member port lets through, in percent of its speed. 1 when absent. */
|
|
172
|
-
storm_percent?: number;
|
|
173
|
-
};
|
|
174
|
-
/**
|
|
175
|
-
* Member ports and a check for an internet exchange's fabric.
|
|
176
|
-
*
|
|
177
|
-
* - `ports(device)`: every member's port on one switch. A member port is in the peering VLAN and nothing else, takes no part in spanning tree or LLDP, and lets only a trickle of broadcast, multicast and unknown unicast through.
|
|
178
|
-
* - `check`: members never share a name, an AS, an address or a port; every address is inside the peering LAN and not reserved; every member port carries the peering VLAN alone.
|
|
179
|
-
*/
|
|
180
|
-
export declare function internetExchange<const V extends string>(exchange: InternetExchange<V>, members: readonly ExchangeMember[]): {
|
|
181
|
-
ports: (device: string) => Record<string, Port<V, string, string, string>>;
|
|
182
|
-
check: Check;
|
|
183
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// Every model each platform supports. Types read from here, so a model or port name that does not exist fails to compile.
|
|
2
|
-
|
|
3
|
-
import { models as fortios } from "./fortios/models";
|
|
4
|
-
import { models as junos } from "./junos/models";
|
|
5
|
-
import { models as raisecom } from "./raisecom-ros/models";
|
|
6
|
-
import { models as routeros } from "./routeros/models";
|
|
7
|
-
import { models as vrp } from "./vrp/models";
|
|
8
|
-
|
|
9
|
-
export const catalog = { routeros, vrp, "raisecom-ros": raisecom, junos, fortios } as const;
|
|
10
|
-
|
|
11
|
-
export type Catalog = typeof catalog;
|
|
12
|
-
export type PlatformName = keyof Catalog;
|
|
13
|
-
export type ModelName<Pl extends PlatformName> = keyof Catalog[Pl] & string;
|
|
14
|
-
|
|
15
|
-
type Upto<N extends number, A extends unknown[] = [], R = never> = A["length"] extends N
|
|
16
|
-
? R
|
|
17
|
-
: Upto<N, [...A, 0], R | `${[...A, 0]["length"]}`>;
|
|
18
|
-
type PortsOf<Pl extends PlatformName, M extends ModelName<Pl>> = Catalog[Pl][M] extends { ports: infer P } ? P : never;
|
|
19
|
-
|
|
20
|
-
/** `10g-1` to `10g-48` on a model with 48 10G ports. */
|
|
21
|
-
export type PortName<Pl extends PlatformName, M extends ModelName<Pl>> = {
|
|
22
|
-
[S in keyof PortsOf<Pl, M>]: `${S & string}-${Upto<PortsOf<Pl, M>[S] & number>}`;
|
|
23
|
-
}[keyof PortsOf<Pl, M>];
|
|
24
|
-
|
|
25
|
-
/** Every port a model has, in order. */
|
|
26
|
-
export function portsOf(platform: string, model: string): string[] {
|
|
27
|
-
const spec = (catalog as Record<string, Record<string, { ports: Record<string, number> }>>)[platform]?.[model];
|
|
28
|
-
if (!spec) throw new Error(`${platform} has no model ${model}`);
|
|
29
|
-
return Object.entries(spec.ports).flatMap(([speed, count]) => Array.from({ length: count }, (_, i) => `${speed}-${i + 1}`));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** The platform's own name for a port. */
|
|
33
|
-
export function spell(platform: string, model: string, port: string): string {
|
|
34
|
-
const spec = (catalog as Record<string, Record<string, { spelling: Record<string, string> }>>)[platform]?.[model];
|
|
35
|
-
const parts = /^(\d+[gm])-(\d+)$/.exec(port);
|
|
36
|
-
const template = parts && spec?.spelling[parts[1]!];
|
|
37
|
-
if (!template) throw new Error(`${model} has no port ${port}`);
|
|
38
|
-
|
|
39
|
-
// A platform that counts from 0, or numbers one class after another, shifts the position: `{n-1}`, `{n+47}`.
|
|
40
|
-
return template.replace(/\{n([+-]\d+)?\}/, (_, shift?: string) => String(Number(parts[2]) + Number(shift ?? 0)));
|
|
41
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// Values more than one adapter derives from a device in the same way.
|
|
2
|
-
|
|
3
|
-
import { familyOf, network } from "../../core/addr";
|
|
4
|
-
import type { Device } from "../../schema";
|
|
5
|
-
|
|
6
|
-
/** Each LAG's number: its own `id`, or its position among the device's LAGs. */
|
|
7
|
-
export function lagIds(device: Device): Map<string, number> {
|
|
8
|
-
const numbers = new Map<string, number>();
|
|
9
|
-
let position = 0;
|
|
10
|
-
|
|
11
|
-
for (const [name, iface] of Object.entries(device.interfaces ?? {})) {
|
|
12
|
-
if (iface.type !== "lag") continue;
|
|
13
|
-
|
|
14
|
-
position++;
|
|
15
|
-
numbers.set(name, iface.id ?? position);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return numbers;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** The IPv4 networks of a port's or an interface's addresses. */
|
|
22
|
-
export function ipv4Networks(device: Device, iface: string): string[] {
|
|
23
|
-
const settings = device.interfaces?.[iface] ?? device.ports?.[iface as keyof typeof device.ports];
|
|
24
|
-
const addresses = (settings?.addresses ?? []).map((entry) => (typeof entry === "string" ? entry : entry.address));
|
|
25
|
-
|
|
26
|
-
return addresses.filter((address) => familyOf(address) === "ipv4").map((address) => network(address));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Services the switch platforms run. Each takes its sources from `management.allow`, on the protocol's own port. */
|
|
30
|
-
const SWITCH_SERVICES = ["ssh", "telnet", "snmp"] as const;
|
|
31
|
-
|
|
32
|
-
/** Fields neither switch platform, VRP nor Raisecom ROS, expresses: a service's own sources or port, a user's description or keys, the IP stack's host settings, a point-to-point address, and offload per interface. */
|
|
33
|
-
export function switchUnsupported(device: Device): string[] {
|
|
34
|
-
const found: string[] = [];
|
|
35
|
-
|
|
36
|
-
for (const service of SWITCH_SERVICES) {
|
|
37
|
-
const settings = device.management?.[service];
|
|
38
|
-
if (settings?.allow) found.push(`management.${service}.allow, every service takes management.allow`);
|
|
39
|
-
if (settings?.port) found.push(`management.${service}.port`);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
for (const [name, user] of Object.entries(device.users ?? {})) {
|
|
43
|
-
if (user.description) found.push(`users.${name}.description`);
|
|
44
|
-
if (user.ssh_keys?.length) found.push(`users.${name}.ssh_keys`);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (device.system?.ip) found.push("system.ip");
|
|
48
|
-
|
|
49
|
-
for (const [name, port] of Object.entries(device.ports ?? {})) {
|
|
50
|
-
if (port?.hardware_offload !== undefined) found.push(`ports.${name}.hardware_offload`);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
for (const [name, iface] of Object.entries(device.interfaces ?? {})) {
|
|
54
|
-
if (iface.addresses?.some((entry) => typeof entry !== "string")) found.push(`interfaces.${name}.addresses with a peer`);
|
|
55
|
-
if (iface.hardware_offload !== undefined) found.push(`interfaces.${name}.hardware_offload`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return found;
|
|
59
|
-
}
|