@takodotid/circuit 0.43.1 → 1.0.0-rc.2

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 (256) hide show
  1. package/README.md +115 -37
  2. package/package.json +21 -58
  3. package/src/checks/across.ts +402 -0
  4. package/src/checks/built-in.ts +256 -0
  5. package/src/checks/device.ts +436 -0
  6. package/src/checks/index.ts +53 -0
  7. package/src/cli/advisories.ts +108 -0
  8. package/src/cli/app.ts +71 -0
  9. package/src/cli/editor-types.generated.ts +30 -0
  10. package/src/cli/editor-types.ts +69 -0
  11. package/src/cli/format.ts +124 -0
  12. package/src/cli/git-hooks.ts +79 -0
  13. package/src/cli/index.ts +350 -1170
  14. package/src/cli/migrate.ts +554 -0
  15. package/src/cli/project-commands.ts +656 -0
  16. package/src/cli/releases.ts +374 -0
  17. package/src/cli/remember.ts +339 -0
  18. package/src/cli/rename.ts +27 -33
  19. package/src/cli/secrets-password.ts +60 -0
  20. package/src/cli/secrets.ts +258 -0
  21. package/src/cli/setup.ts +300 -0
  22. package/src/cli/signing.ts +23 -0
  23. package/src/cli/text-editor.ts +268 -0
  24. package/src/cli/ui.ts +298 -0
  25. package/src/cli/version.ts +2 -0
  26. package/src/cli/versions.ts +158 -0
  27. package/src/config/address.ts +102 -0
  28. package/src/config/circuit.d.ts +30 -0
  29. package/src/config/common.ts +65 -0
  30. package/src/config/communities.ts +479 -0
  31. package/src/config/define.ts +684 -0
  32. package/src/config/device.ts +164 -0
  33. package/src/config/firewall.ts +150 -0
  34. package/src/config/index.ts +22 -0
  35. package/src/{schema → config}/interfaces.ts +121 -85
  36. package/src/config/keys.ts +434 -0
  37. package/src/config/management.ts +61 -0
  38. package/src/config/merge.ts +335 -0
  39. package/src/config/models.ts +70 -0
  40. package/src/config/monitoring.ts +64 -0
  41. package/src/config/network.ts +180 -0
  42. package/src/config/presets.ts +149 -0
  43. package/src/config/routing.ts +401 -0
  44. package/src/config/services.ts +51 -0
  45. package/src/config/switching.ts +84 -0
  46. package/src/config/system.ts +103 -0
  47. package/src/{schema → config}/time-zones.ts +1 -1
  48. package/src/core/address.ts +1 -1
  49. package/src/core/cabling.ts +8 -43
  50. package/src/core/graph.ts +40 -0
  51. package/src/{integrations → core}/registries.ts +5 -3
  52. package/src/core/secrets-file.ts +539 -0
  53. package/src/core/secrets.ts +83 -64
  54. package/src/core/topology.ts +103 -146
  55. package/src/core/utils.ts +12 -1
  56. package/src/model.ts +83 -0
  57. package/src/platforms/derive.ts +64 -37
  58. package/src/platforms/finding.ts +9 -0
  59. package/src/platforms/fortios/firewall.ts +76 -64
  60. package/src/platforms/fortios/index.ts +189 -125
  61. package/src/platforms/fortios/names.ts +51 -18
  62. package/src/platforms/fortios/render.ts +69 -62
  63. package/src/platforms/fortios/routing.ts +89 -58
  64. package/src/platforms/fortios/vdoms.ts +47 -16
  65. package/src/platforms/junos/TRAPS.md +2 -2
  66. package/src/platforms/junos/bgp.ts +63 -42
  67. package/src/platforms/junos/index.ts +122 -89
  68. package/src/platforms/junos/render.ts +139 -104
  69. package/src/platforms/platform.ts +10 -8
  70. package/src/platforms/raisecom-ros/TRAPS.md +1 -1
  71. package/src/platforms/raisecom-ros/index.ts +89 -70
  72. package/src/platforms/raisecom-ros/render.ts +49 -45
  73. package/src/platforms/routeros/TRAPS.md +3 -3
  74. package/src/platforms/routeros/index.ts +121 -60
  75. package/src/platforms/routeros/render.ts +214 -195
  76. package/src/platforms/vrp/TRAPS.md +1 -1
  77. package/src/platforms/vrp/index.ts +74 -50
  78. package/src/platforms/vrp/render.ts +67 -56
  79. package/src/project/project.ts +725 -0
  80. package/src/studio/app/env.d.ts +9 -0
  81. package/src/studio/app/index.html +18 -0
  82. package/src/studio/app/src/App.vue +95 -0
  83. package/src/studio/app/src/components/AddressesView.vue +38 -0
  84. package/src/studio/app/src/components/CablesView.vue +29 -0
  85. package/src/studio/app/src/components/CompareView.vue +160 -0
  86. package/src/studio/app/src/components/DataTable.vue +49 -0
  87. package/src/studio/app/src/components/DeviceView.vue +237 -0
  88. package/src/studio/app/src/components/DevicesView.vue +32 -0
  89. package/src/studio/app/src/components/Faceplate.vue +75 -0
  90. package/src/studio/app/src/components/GraphView.vue +282 -0
  91. package/src/studio/app/src/components/LineDiff.vue +24 -0
  92. package/src/studio/app/src/components/ProblemsView.vue +42 -0
  93. package/src/studio/app/src/components/SearchView.vue +72 -0
  94. package/src/studio/app/src/components/SecretsView.vue +112 -0
  95. package/src/studio/app/src/components/SessionsView.vue +35 -0
  96. package/src/studio/app/src/components/Settings.vue +95 -0
  97. package/src/studio/app/src/components/ToolsView.vue +118 -0
  98. package/src/studio/app/src/components/VlansView.vue +50 -0
  99. package/src/studio/app/src/lib/csv.ts +19 -0
  100. package/src/studio/{public/diff.js → app/src/lib/diff.ts} +40 -35
  101. package/src/studio/app/src/lib/format.ts +38 -0
  102. package/src/studio/app/src/lib/net.ts +68 -0
  103. package/src/studio/app/src/lib/secrets-crypto.ts +35 -0
  104. package/src/studio/app/src/lib/store.ts +71 -0
  105. package/src/studio/app/src/lib/tools.ts +217 -0
  106. package/src/studio/app/src/main.ts +9 -0
  107. package/src/studio/{public → app/src}/style.css +14 -4
  108. package/src/studio/app/tsconfig.json +17 -0
  109. package/src/studio/app/vite.config.ts +16 -0
  110. package/src/studio/assets.generated.ts +3 -0
  111. package/src/studio/data.ts +96 -188
  112. package/src/studio/git.ts +27 -43
  113. package/src/studio/server.ts +196 -107
  114. package/src/studio/types.ts +141 -0
  115. package/src/transport/console.ts +3 -3
  116. package/src/transport/ssh.ts +1 -1
  117. package/dist/chunks/index-3b343xva.js +0 -177
  118. package/dist/chunks/index-6wb41q67.js +0 -62
  119. package/dist/chunks/index-n7w3tg5y.js +0 -149
  120. package/dist/chunks/index-yzw86rc8.js +0 -921
  121. package/dist/chunks/new-w3zys5y4.js +0 -172
  122. package/dist/chunks/server-cxr9ynxc.js +0 -259
  123. package/dist/cli/index.js +0 -12922
  124. package/dist/helpers/index.js +0 -881
  125. package/dist/index.js +0 -28
  126. package/dist/types/core/address-space.d.ts +0 -62
  127. package/dist/types/core/address.d.ts +0 -44
  128. package/dist/types/core/cabling.d.ts +0 -41
  129. package/dist/types/core/cross-checks.d.ts +0 -28
  130. package/dist/types/core/define.d.ts +0 -79
  131. package/dist/types/core/project-files.d.ts +0 -12
  132. package/dist/types/core/schema-docs.d.ts +0 -25
  133. package/dist/types/core/secrets.d.ts +0 -62
  134. package/dist/types/core/topology.d.ts +0 -96
  135. package/dist/types/core/utils.d.ts +0 -10
  136. package/dist/types/core/validator.d.ts +0 -23
  137. package/dist/types/helpers/bgp.d.ts +0 -195
  138. package/dist/types/helpers/cables.d.ts +0 -69
  139. package/dist/types/helpers/checks.d.ts +0 -36
  140. package/dist/types/helpers/exchange.d.ts +0 -55
  141. package/dist/types/helpers/filters.d.ts +0 -51
  142. package/dist/types/helpers/index.d.ts +0 -14
  143. package/dist/types/helpers/route-server.d.ts +0 -52
  144. package/dist/types/helpers/upstreams.d.ts +0 -192
  145. package/dist/types/index.d.ts +0 -10
  146. package/dist/types/integrations/librenms.d.ts +0 -60
  147. package/dist/types/integrations/netbox.d.ts +0 -89
  148. package/dist/types/integrations/peeringdb.d.ts +0 -24
  149. package/dist/types/integrations/prometheus.d.ts +0 -24
  150. package/dist/types/integrations/registries.d.ts +0 -8
  151. package/dist/types/platforms/bgp-wait.d.ts +0 -24
  152. package/dist/types/platforms/catalog.d.ts +0 -109
  153. package/dist/types/platforms/derive.d.ts +0 -17
  154. package/dist/types/platforms/fortios/firewall.d.ts +0 -47
  155. package/dist/types/platforms/fortios/index.d.ts +0 -140
  156. package/dist/types/platforms/fortios/models.d.ts +0 -14
  157. package/dist/types/platforms/fortios/names.d.ts +0 -52
  158. package/dist/types/platforms/fortios/plan.d.ts +0 -114
  159. package/dist/types/platforms/fortios/render.d.ts +0 -77
  160. package/dist/types/platforms/fortios/routing.d.ts +0 -56
  161. package/dist/types/platforms/fortios/tree.d.ts +0 -37
  162. package/dist/types/platforms/fortios/vdoms.d.ts +0 -50
  163. package/dist/types/platforms/index.d.ts +0 -13
  164. package/dist/types/platforms/junos/bgp.d.ts +0 -44
  165. package/dist/types/platforms/junos/index.d.ts +0 -114
  166. package/dist/types/platforms/junos/models.d.ts +0 -14
  167. package/dist/types/platforms/junos/render.d.ts +0 -154
  168. package/dist/types/platforms/line-diff.d.ts +0 -67
  169. package/dist/types/platforms/platform.d.ts +0 -135
  170. package/dist/types/platforms/raisecom-ros/index.d.ts +0 -71
  171. package/dist/types/platforms/raisecom-ros/models.d.ts +0 -14
  172. package/dist/types/platforms/raisecom-ros/render.d.ts +0 -41
  173. package/dist/types/platforms/routeros/export.d.ts +0 -59
  174. package/dist/types/platforms/routeros/index.d.ts +0 -116
  175. package/dist/types/platforms/routeros/models.d.ts +0 -18
  176. package/dist/types/platforms/routeros/plan.d.ts +0 -58
  177. package/dist/types/platforms/routeros/render.d.ts +0 -250
  178. package/dist/types/platforms/vrp/index.d.ts +0 -83
  179. package/dist/types/platforms/vrp/models.d.ts +0 -12
  180. package/dist/types/platforms/vrp/render.d.ts +0 -96
  181. package/dist/types/schema/common.d.ts +0 -30
  182. package/dist/types/schema/device.d.ts +0 -126
  183. package/dist/types/schema/firewall.d.ts +0 -131
  184. package/dist/types/schema/index.d.ts +0 -8
  185. package/dist/types/schema/interfaces.d.ts +0 -205
  186. package/dist/types/schema/policy.d.ts +0 -107
  187. package/dist/types/schema/routing.d.ts +0 -161
  188. package/dist/types/schema/system.d.ts +0 -198
  189. package/dist/types/schema/time-zones.d.ts +0 -2
  190. package/dist/types/transport/console.d.ts +0 -115
  191. package/dist/types/transport/path-check.d.ts +0 -32
  192. package/dist/types/transport/ssh.d.ts +0 -27
  193. package/src/cli/graph-format.ts +0 -91
  194. package/src/cli/new.ts +0 -234
  195. package/src/core/address-space.ts +0 -320
  196. package/src/core/cross-checks.ts +0 -369
  197. package/src/core/define.ts +0 -124
  198. package/src/core/project-files.ts +0 -35
  199. package/src/core/schema-docs.ts +0 -174
  200. package/src/core/validator.ts +0 -508
  201. package/src/helpers/bgp.ts +0 -473
  202. package/src/helpers/cables.ts +0 -74
  203. package/src/helpers/checks.ts +0 -201
  204. package/src/helpers/exchange.ts +0 -123
  205. package/src/helpers/filters.ts +0 -107
  206. package/src/helpers/index.ts +0 -25
  207. package/src/helpers/route-server.ts +0 -212
  208. package/src/helpers/upstreams.ts +0 -369
  209. package/src/index.ts +0 -13
  210. package/src/integrations/librenms.ts +0 -291
  211. package/src/integrations/netbox.ts +0 -620
  212. package/src/integrations/peeringdb.ts +0 -173
  213. package/src/integrations/prometheus.ts +0 -90
  214. package/src/schema/common.ts +0 -41
  215. package/src/schema/device.ts +0 -145
  216. package/src/schema/firewall.ts +0 -140
  217. package/src/schema/index.ts +0 -8
  218. package/src/schema/policy.ts +0 -115
  219. package/src/schema/routing.ts +0 -173
  220. package/src/schema/system.ts +0 -203
  221. package/src/studio/public/app.js +0 -186
  222. package/src/studio/public/compare.js +0 -250
  223. package/src/studio/public/dom.js +0 -138
  224. package/src/studio/public/evaluate.js +0 -687
  225. package/src/studio/public/export.js +0 -130
  226. package/src/studio/public/graph.js +0 -1541
  227. package/src/studio/public/index.html +0 -83
  228. package/src/studio/public/net.js +0 -134
  229. package/src/studio/public/tables.js +0 -1289
  230. package/src/studio/public/tools.js +0 -610
  231. package/templates/colocation/checks.ts +0 -53
  232. package/templates/colocation/circuit.config.ts +0 -9
  233. package/templates/colocation/edge-01.ts +0 -133
  234. package/templates/colocation/routing.ts +0 -13
  235. package/templates/colocation/tenancy.ts +0 -76
  236. package/templates/colocation/tenants/acme.ts +0 -19
  237. package/templates/colocation/tenants/index.ts +0 -6
  238. package/templates/colocation/tor-01.ts +0 -33
  239. package/templates/edge-router/checks.ts +0 -20
  240. package/templates/edge-router/circuit.config.ts +0 -8
  241. package/templates/edge-router/edge-01.ts +0 -110
  242. package/templates/edge-router/routing.ts +0 -13
  243. package/templates/project/AGENTS.md +0 -51
  244. package/templates/project/CLAUDE.md +0 -1
  245. package/templates/project/README.md +0 -16
  246. package/templates/project/gitignore +0 -5
  247. package/templates/project/tsconfig.json +0 -13
  248. package/templates/single-site/checks.ts +0 -26
  249. package/templates/single-site/circuit.config.ts +0 -8
  250. package/templates/single-site/router.ts +0 -86
  251. package/templates/single-site/site.ts +0 -18
  252. package/templates/single-site/switch.ts +0 -34
  253. /package/src/studio/{public → app/public}/favicon.svg +0 -0
  254. /package/src/studio/{public → app/public}/special-gothic-latin-ext.woff2 +0 -0
  255. /package/src/studio/{public → app/public}/special-gothic-latin.woff2 +0 -0
  256. /package/src/studio/{public → app/public}/special-gothic-license.txt +0 -0
@@ -1,107 +0,0 @@
1
- import type { Family, IP, Prefix } from "./common.js";
2
- /** A standard BGP community, `asn:value`, for example `64500:100`. Each part is 0 to 65535. */
3
- export type StandardCommunity = `${number}:${number}`;
4
- /** A large BGP community, `asn:function:parameter`, for example `64500:1:6939`. Each part is 0 to 4294967295. */
5
- export type LargeCommunity = `${number}:${number}:${number}`;
6
- /** A standard community to remove. `*` stands for any value of a part, as in `64500:*`. */
7
- export type StandardCommunityPattern = `${number | "*"}:${number | "*"}`;
8
- /** A large community to remove. `*` stands for any value of a part, as in `64500:*:*`. */
9
- export type LargeCommunityPattern = `${number | "*"}:${number | "*"}:${number | "*"}`;
10
- /** Registries a prefix set can be fetched from. */
11
- export type Registry = "ripe-stat";
12
- /** Prefixes listed here, or fetched from a registry by `refresh` and never typed by hand. */
13
- export type PrefixSet = {
14
- /** The prefixes, of one family. */
15
- prefixes: readonly Prefix[];
16
- } | {
17
- source: {
18
- /** Where the prefixes come from. */
19
- registry: Registry;
20
- /** What to ask for, for example `AS7713`. */
21
- query: string;
22
- /** Which family to keep. */
23
- family: Family;
24
- };
25
- };
26
- /** Conditions on a route. All must be true. An empty match is true for every route. */
27
- export type Match<S extends string> = {
28
- /** Only routes of this family. */
29
- family?: Family;
30
- /** Exactly this prefix. */
31
- prefix?: Prefix;
32
- /** Any prefix in this set. */
33
- prefix_set?: S;
34
- /** Prefix length within this range, inclusive. */
35
- prefix_length?: {
36
- min?: number;
37
- max?: number;
38
- };
39
- /** AS path length within this range, inclusive. Every AS counts, prepends included. */
40
- as_path_length?: {
41
- min?: number;
42
- max?: number;
43
- };
44
- /** The AS path holds this AS anywhere: the route came from it or through it. */
45
- through_as?: number;
46
- /** The route's origin validation state. */
47
- rpki?: "valid" | "invalid" | "not-found";
48
- /** Has this standard community, `asn:value`. */
49
- community?: StandardCommunity;
50
- /** Has this large community, `asn:function:parameter`. */
51
- large_community?: LargeCommunity;
52
- };
53
- /** Changes to a route. In community lists to remove, `*` stands for any value of a field, as in `64500:*:*`. */
54
- export type Sets = {
55
- /** Preference among routes to the same prefix within our AS. Higher wins. */
56
- local_pref?: number;
57
- /** Multi-exit discriminator offered to the neighbor. Lower wins. */
58
- med?: number;
59
- /** Prepend our own AS this many times, to make the path look longer. */
60
- prepend?: number;
61
- /** Replace the route's standard communities with these. */
62
- communities?: readonly StandardCommunity[];
63
- /** Add these standard communities. */
64
- add_communities?: readonly StandardCommunity[];
65
- /** Remove standard communities matching these. A part may be `*`. */
66
- remove_communities?: readonly StandardCommunityPattern[];
67
- /** Replace the route's large communities with these. */
68
- large_communities?: readonly LargeCommunity[];
69
- /** Add these large communities. */
70
- add_large_communities?: readonly LargeCommunity[];
71
- /** Remove large communities matching these. A part may be `*`. */
72
- remove_large_communities?: readonly LargeCommunityPattern[];
73
- /** Next hop for the route. */
74
- next_hop?: IP;
75
- /** Source address for traffic the device itself sends to the route. Applies to routes of the same family as the address. */
76
- preferred_source?: IP;
77
- /** Drop traffic to the route on this device, instead of forwarding it. */
78
- blackhole?: true;
79
- };
80
- /**
81
- * Run another policy at this point. A route it accepts or rejects stops there; any other route goes on to the next rule. A call holds nothing else: to call a policy for some routes only, put the match inside that policy.
82
- */
83
- export type CallRule<P extends string> = {
84
- /** Shown beside the rule on the device. */
85
- description?: string;
86
- /** The policy to run. */
87
- call: P;
88
- match?: never;
89
- set?: never;
90
- action?: never;
91
- };
92
- /** Change and decide on the routes that match. A rule without `action` changes the route and moves on to the next rule. */
93
- export type MatchRule<S extends string> = {
94
- /** Shown beside the rule on the device. */
95
- description?: string;
96
- call?: never;
97
- /** Which routes the rule applies to. Every route when absent. */
98
- match?: Match<S>;
99
- /** What to change on a matching route. */
100
- set?: Sets;
101
- /** Accept or reject a matching route, ending the policy for it. */
102
- action?: "accept" | "reject";
103
- };
104
- /** One step of a route policy: a call to another policy, or a rule that matches routes, changes them and may decide on them. */
105
- export type PolicyRule<P extends string, S extends string> = CallRule<P> | MatchRule<S>;
106
- /** Rules evaluated in order, first decision wins. A route no rule accepts is rejected. */
107
- export type RoutePolicy<P extends string, S extends string> = readonly PolicyRule<P, S>[];
@@ -1,161 +0,0 @@
1
- import type { Family, IP, Prefix, Secret } from "./common.js";
2
- /** A route the device has without learning it. */
3
- export type StaticRoute<I extends string, F extends string, T extends string = never> = {
4
- /** Destination. */
5
- prefix: Prefix;
6
- /** Next-hop address. */
7
- via?: IP;
8
- /** Next-hop interface, for a link without a next-hop address. */
9
- interface?: I;
10
- /** Discard matching traffic. The usual way to originate an aggregate. */
11
- blackhole?: true;
12
- /** Withdraw the route while BFD finds `via` dead, and put it back once `via` answers again. Needs `via`. */
13
- bfd?: true;
14
- /** Preference against other routes to the same prefix. Lower wins. 1 when absent. */
15
- distance?: number;
16
- /** The VRF the route is in. The main table when absent. */
17
- vrf?: F;
18
- /** The table the route is in: `main`, or one of `routing.tables`. The main table when absent; write `main` to say so. A route has a `vrf` or a `table`, not both. */
19
- table?: T | "main";
20
- /** Why the route exists. */
21
- description?: string;
22
- };
23
- /**
24
- * 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.
25
- */
26
- export type BgpRole = "provider" | "customer" | "peer" | "rs" | "rs-client";
27
- /** Settings a BGP neighbor can set itself or take from its group. */
28
- export type NeighborSettings<P extends string, T extends string = never> = {
29
- /** The neighbor's AS. Our own AS makes the session internal. */
30
- remote_as?: number;
31
- /** Who the neighbor is. */
32
- description?: string;
33
- /** Source address for the session. The outgoing interface's address when absent. */
34
- local_address?: IP;
35
- /** Policy for routes learned. Nothing is accepted when absent. */
36
- import?: P;
37
- /** Policy for routes announced. Nothing is announced when absent. */
38
- export?: P;
39
- /** What the neighbor is to us, such as `provider` for a transit. Both sides then reject a route leak, as RFC 9234 describes. */
40
- role?: BgpRole;
41
- /** The neighbor is more than one hop away. */
42
- multihop?: boolean;
43
- /** TCP MD5 password shared with the neighbor. */
44
- password?: Secret;
45
- /** Close the session when the neighbor announces more prefixes than this. It stays closed until cleared by hand, on RouterOS with `/routing bgp session clear <session> flag=limit-exceeded`. */
46
- max_prefixes?: number;
47
- /** Seconds without a message before the session is declared down. */
48
- hold_time?: number;
49
- /** Seconds between keepalive messages. */
50
- keepalive?: number;
51
- /** Families exchanged. The family of the neighbor's address when absent. */
52
- families?: readonly Family[];
53
- /** Wait for the neighbor to connect instead of connecting to it. */
54
- passive?: boolean;
55
- /** Detect a dead link in under a second with BFD. */
56
- bfd?: boolean;
57
- /** The table the routes learned are installed in: `main`, or one of `routing.tables`. The main table when absent; write `main` to say so. On RouterOS the session also announces from that table, so each prefix of `networks` it announces needs a route in the table too, and a running session takes a new table only when it restarts. */
58
- table?: T | "main";
59
- };
60
- /** One BGP session. Settings it does not set come from its group. */
61
- export type Neighbor<P extends string, G extends string, T extends string = never> = NeighborSettings<P, T> & {
62
- /** The neighbor's address. */
63
- address: IP;
64
- /** The group this neighbor takes a setting from when it does not set that setting itself. */
65
- group?: NoInfer<G>;
66
- };
67
- /** BGP on this device. */
68
- export type Bgp<P extends string, G extends string, T extends string = never> = {
69
- /** Our AS number. */
70
- asn: number;
71
- /** Prefixes this device originates. Each needs a route, for example a static blackhole. Export policy still decides who receives them. */
72
- networks?: readonly Prefix[];
73
- /** Settings shared by several neighbors, keyed by group name. */
74
- groups?: Record<G, NeighborSettings<P, T>>;
75
- /** Sessions keyed by name. */
76
- neighbors?: Record<string, Neighbor<P, G, T>>;
77
- };
78
- /** How fast BFD notices a dead neighbor: after `multiplier` packets in a row are missed, so in `interval` times `multiplier` milliseconds. */
79
- export type Bfd = {
80
- /** Milliseconds between the packets this device sends, and the shortest gap it asks of the neighbor. */
81
- interval: number;
82
- /** How many packets in a row may be missed before the neighbor is declared down. */
83
- multiplier: number;
84
- };
85
- /** A route origin validation server, RFC 8210. */
86
- export type RpkiServer = {
87
- /** Where the validator listens. */
88
- address: IP;
89
- /** Its RTR port, often 323 or 8282. */
90
- port: number;
91
- /** Who runs it, or why it is here. */
92
- description?: string;
93
- };
94
- /** OSPF on one interface. */
95
- export type OspfInterface = {
96
- /** Cost of sending through this interface. Lower is preferred. Derived from speed when absent. */
97
- cost?: number;
98
- /** Advertise the interface's network but form no adjacency on it. */
99
- passive?: boolean;
100
- /** How the link is treated. Broadcast when absent. */
101
- network?: "broadcast" | "point-to-point";
102
- /** Detect a dead neighbor in under a second with BFD. */
103
- bfd?: boolean;
104
- };
105
- /** An OSPF area ID, written as four numbers with dots between them, for example `0.0.0.0` for the backbone. */
106
- export type OspfAreaId = `${number}.${number}.${number}.${number}`;
107
- /** OSPF, version 2 for IPv4 and version 3 for IPv6. */
108
- export type Ospf<I extends string> = {
109
- /** Which versions run. IPv4 when absent. */
110
- families?: readonly Family[];
111
- /** Areas keyed by area ID, for example `0.0.0.0`, each with the interfaces in it. */
112
- areas: Record<OspfAreaId, {
113
- interfaces: Partial<Record<I, OspfInterface>>;
114
- }>;
115
- /** Routes from other sources announced into OSPF. */
116
- redistribute?: readonly ("connected" | "static")[];
117
- };
118
- /** A routing table beside the main one. It holds no interfaces: routes go in from static routes and BGP neighbors that name it in `table`, and `routing.rules` send traffic to it. */
119
- export type RoutingTable = {
120
- /** What the table is for. */
121
- description?: string;
122
- };
123
- /** Traffic a routing rule matches: all of what is given. Every packet when absent. */
124
- export type RoutingRuleMatch<I extends string> = {
125
- /** Source prefix. */
126
- src?: Prefix;
127
- /** Destination prefix. */
128
- dst?: Prefix;
129
- /** The interface the traffic arrives on. */
130
- in_interface?: I;
131
- };
132
- /** One routing rule: traffic it matches is routed by `table` instead of the main table. */
133
- export type RoutingRule<I extends string, T extends string> = {
134
- /** Why the rule exists. */
135
- description?: string;
136
- /** What the traffic must match. Every packet when absent, so such a rule is the last one. */
137
- match?: RoutingRuleMatch<I>;
138
- /** The table that routes the traffic: one of `routing.tables`, or `main`. */
139
- table: T | "main";
140
- /** When `table` has no route for a packet: `none` drops it as unroutable, `main` routes it by the main table instead. `none` when absent. Not for a rule whose table is `main`. */
141
- fallback?: "none" | "main";
142
- };
143
- /** Routing on this device. */
144
- export type Routing<P extends string, G extends string, I extends string, F extends string, T extends string = never> = {
145
- /** Identifies this router to its neighbors. */
146
- router_id?: IP;
147
- /** Routing tables beside the main one, keyed by name. Not `main`, and not the name of a VRF. */
148
- tables?: Record<T, RoutingTable>;
149
- /** Rules that route matching traffic by another table, such as traffic from one block by its own transits' default. In order: the first that matches decides, and traffic no rule matches is routed by the main table. */
150
- rules?: readonly RoutingRule<I, NoInfer<T>>[];
151
- /** Routes the device has without learning them. */
152
- static?: readonly StaticRoute<I, F, NoInfer<T>>[];
153
- /** BGP sessions and what they exchange. */
154
- bgp?: Bgp<P, G, NoInfer<T>>;
155
- /** OSPF areas and interfaces. */
156
- ospf?: Ospf<I>;
157
- /** Validators answering route origin validation. */
158
- rpki?: readonly RpkiServer[];
159
- /** BFD timers for every BFD session on the device: BGP, OSPF and static routes. The platform's own when absent; Junos has none, so Circuit sends every 300 ms there. Both ends of a link should agree. */
160
- bfd?: Bfd;
161
- };
@@ -1,198 +0,0 @@
1
- import type { IP, MacAddress, Prefix, Secret, Severity } from "./common.js";
2
- import type { TimeZone } from "./time-zones.js";
3
- /** A software release track, as RouterOS names them. `long-term` changes least; `development` is the newest and least tested. */
4
- export type ReleaseChannel = "long-term" | "stable" | "testing" | "development";
5
- /** How bad an alarm is, most severe first, as ITU-T X.733 ranks them. */
6
- export type AlarmSeverity = "critical" | "major" | "minor" | "warning";
7
- /** Device-wide settings. */
8
- export type System = {
9
- /** IANA zone, for example `Asia/Jakarta`. The editor suggests every name. UTC when absent. */
10
- timezone?: TimeZone;
11
- /** Shown at login. */
12
- banner?: string;
13
- /** Resolvers the device uses. */
14
- dns?: {
15
- /** Resolvers, in order of preference. */
16
- servers: readonly IP[];
17
- /** Answer queries from others. Off when absent. */
18
- serve?: boolean;
19
- };
20
- /** How the device keeps time. */
21
- ntp?: {
22
- /** Time sources, by address or name. */
23
- servers: readonly string[];
24
- /** Answer time queries from others. Off when absent. */
25
- serve?: boolean;
26
- };
27
- /** Where log messages go. */
28
- logging?: {
29
- /** Kept on the device's own storage, from `level` up. */
30
- local?: {
31
- /** The least severe message kept. */
32
- level: Severity;
33
- /** How many rotated files to keep. */
34
- files?: number;
35
- /** Lines in each file before it rotates. */
36
- lines_per_file?: number;
37
- };
38
- /** Sent to syslog collectors, each from its own `level` up. */
39
- remote?: readonly {
40
- address: IP;
41
- /** UDP port. 514 when absent. */
42
- port?: number;
43
- /** The least severe message sent. */
44
- level: Severity;
45
- }[];
46
- };
47
- /** Software release track the device updates from. `stable` when absent. */
48
- release_channel?: ReleaseChannel;
49
- /** Alarms raised at another severity than the platform's own, keyed by the alarm's name as the platform spells it, such as `hwOpticalUnAuthorized` on VRP. */
50
- alarms?: Record<string, {
51
- severity: AlarmSeverity;
52
- }>;
53
- /** Read optic temperature, power and voltage. */
54
- transceiver_monitoring?: boolean;
55
- /** Host behaviour of the IP stack. */
56
- ip?: {
57
- /** Send ICMP redirects. Off when absent. */
58
- icmp_redirects?: boolean;
59
- /** Answer a TCP SYN flood with SYN cookies. Off when absent. */
60
- syn_cookies?: boolean;
61
- };
62
- };
63
- /** A login on the device. */
64
- export type User = {
65
- /** What the user may do. */
66
- role: "admin" | "operator" | "read-only";
67
- /** The login password. */
68
- password: Secret;
69
- /** Who the account is for. */
70
- description?: string;
71
- /** Public keys accepted instead of the password over SSH. */
72
- ssh_keys?: readonly string[];
73
- };
74
- /** A way into the device. Absent means turned off. */
75
- export type Service = {
76
- /** Sources allowed. `management.allow` when absent. */
77
- allow?: readonly Prefix[];
78
- /** TCP or UDP port. The protocol's own when absent. */
79
- port?: number;
80
- };
81
- /** One SNMPv3 user. */
82
- export type SnmpUser = {
83
- /** How messages are authenticated. */
84
- auth: "sha1" | "sha256";
85
- /** The authentication passphrase. */
86
- auth_password: Secret;
87
- /** How messages are encrypted. */
88
- privacy: "aes128" | "des";
89
- /** The encryption passphrase. */
90
- privacy_password: Secret;
91
- };
92
- /** How the device is reached and managed. */
93
- export type Management<I extends string, C extends string> = {
94
- /** Sources allowed to every service that does not set its own. */
95
- allow?: readonly Prefix[];
96
- /** The ports and interfaces the services answer on; every other one answers ping alone. Every one with an address when absent. */
97
- interfaces?: readonly I[];
98
- /** Secure shell. */
99
- ssh?: Service & {
100
- /** Also offer legacy ciphers, MACs and key exchanges. Off when absent. */
101
- weak_crypto?: boolean;
102
- /** Seconds a login may take. */
103
- auth_timeout?: number;
104
- /** Failed attempts allowed per connection. */
105
- auth_retries?: number;
106
- };
107
- /** Unencrypted remote login. */
108
- telnet?: Service;
109
- /** Web interface, unencrypted. */
110
- http?: Service;
111
- /** Web interface over TLS. */
112
- https?: Service & {
113
- /** One of the device's `certificates`. */
114
- certificate?: C;
115
- };
116
- /** The platform's own API, unencrypted. */
117
- api?: Service;
118
- /** The platform's own API over TLS. */
119
- api_tls?: Service & {
120
- /** One of the device's `certificates`. */
121
- certificate?: C;
122
- };
123
- /** File transfer, unencrypted. */
124
- ftp?: Service;
125
- /** The platform's own management protocol. `interfaces` also allows it at layer 2 on those interfaces. */
126
- native?: Service & {
127
- interfaces?: readonly I[];
128
- };
129
- /** Polling by SNMP. */
130
- snmp?: Service & {
131
- /** Read-only community for version 2c. Version 2c is off when absent. */
132
- community?: Secret;
133
- /** Version 3 users, keyed by name. */
134
- users?: Record<string, SnmpUser>;
135
- /** Who to contact about the device. */
136
- contact?: string;
137
- /** Where the device is. */
138
- location?: string;
139
- };
140
- /** Console login uses this password. The device's users when absent. */
141
- console?: {
142
- password: Secret;
143
- };
144
- /** Password for privileged mode, on platforms that have one. */
145
- privilege_password?: Secret;
146
- };
147
- /** A DHCP server for one network. */
148
- export type DhcpServer<I extends string> = {
149
- /** Where it answers. */
150
- interface: I;
151
- /** The network it serves. */
152
- network: Prefix;
153
- /** Default gateway given to clients. */
154
- gateway: IP;
155
- /** Resolvers given to clients. */
156
- dns?: readonly IP[];
157
- /** First and last address given to clients. */
158
- pool: readonly [IP, IP];
159
- /** Seconds a lease lasts. */
160
- lease_time?: number;
161
- /** Addresses fixed to a MAC. */
162
- reservations?: readonly {
163
- address: IP;
164
- /** The client's MAC address. */
165
- mac: MacAddress;
166
- /** Whose address it is. */
167
- description?: string;
168
- }[];
169
- };
170
- /** Forward DHCP requests heard on an interface to servers elsewhere. */
171
- export type DhcpRelay<I extends string> = {
172
- /** Where requests are heard. */
173
- interface: I;
174
- /** Where they are forwarded. */
175
- servers: readonly IP[];
176
- };
177
- /** A certificate the device presents or trusts. */
178
- export type Certificate = {
179
- /** The certificate, PEM. Public, so it is kept in the repository. */
180
- certificate: string;
181
- /** 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. */
182
- private_key?: Secret;
183
- };
184
- /** Export flow records or packet samples to collectors. */
185
- export type FlowExport<I extends string> = {
186
- /** The record format. */
187
- protocol: "sflow" | "netflow-v9" | "ipfix";
188
- /** Where records are sent. */
189
- collectors: readonly {
190
- address: IP;
191
- /** UDP port. 6343 for sFlow and 2055 otherwise when absent. */
192
- port?: number;
193
- }[];
194
- /** Sample one packet in this many. Every packet when absent, on a platform that can export every packet. */
195
- sampling?: number;
196
- /** Where traffic is observed. Every interface when absent. */
197
- interfaces?: readonly I[];
198
- };
@@ -1,2 +0,0 @@
1
- /** An IANA time zone name, such as `Asia/Jakarta`, or `UTC`. */
2
- export type TimeZone = "UTC" | "Africa/Abidjan" | "Africa/Accra" | "Africa/Addis_Ababa" | "Africa/Algiers" | "Africa/Asmara" | "Africa/Asmera" | "Africa/Bamako" | "Africa/Bangui" | "Africa/Banjul" | "Africa/Bissau" | "Africa/Blantyre" | "Africa/Brazzaville" | "Africa/Bujumbura" | "Africa/Cairo" | "Africa/Casablanca" | "Africa/Ceuta" | "Africa/Conakry" | "Africa/Dakar" | "Africa/Dar_es_Salaam" | "Africa/Djibouti" | "Africa/Douala" | "Africa/El_Aaiun" | "Africa/Freetown" | "Africa/Gaborone" | "Africa/Harare" | "Africa/Johannesburg" | "Africa/Juba" | "Africa/Kampala" | "Africa/Khartoum" | "Africa/Kigali" | "Africa/Kinshasa" | "Africa/Lagos" | "Africa/Libreville" | "Africa/Lome" | "Africa/Luanda" | "Africa/Lubumbashi" | "Africa/Lusaka" | "Africa/Malabo" | "Africa/Maputo" | "Africa/Maseru" | "Africa/Mbabane" | "Africa/Mogadishu" | "Africa/Monrovia" | "Africa/Nairobi" | "Africa/Ndjamena" | "Africa/Niamey" | "Africa/Nouakchott" | "Africa/Ouagadougou" | "Africa/Porto-Novo" | "Africa/Sao_Tome" | "Africa/Tripoli" | "Africa/Tunis" | "Africa/Windhoek" | "America/Adak" | "America/Anchorage" | "America/Anguilla" | "America/Antigua" | "America/Araguaina" | "America/Argentina/Buenos_Aires" | "America/Argentina/Catamarca" | "America/Argentina/Cordoba" | "America/Argentina/Jujuy" | "America/Argentina/La_Rioja" | "America/Argentina/Mendoza" | "America/Argentina/Rio_Gallegos" | "America/Argentina/Salta" | "America/Argentina/San_Juan" | "America/Argentina/San_Luis" | "America/Argentina/Tucuman" | "America/Argentina/Ushuaia" | "America/Aruba" | "America/Asuncion" | "America/Atikokan" | "America/Bahia" | "America/Bahia_Banderas" | "America/Barbados" | "America/Belem" | "America/Belize" | "America/Blanc-Sablon" | "America/Boa_Vista" | "America/Bogota" | "America/Boise" | "America/Buenos_Aires" | "America/Cambridge_Bay" | "America/Campo_Grande" | "America/Cancun" | "America/Caracas" | "America/Catamarca" | "America/Cayenne" | "America/Cayman" | "America/Chicago" | "America/Chihuahua" | "America/Ciudad_Juarez" | "America/Coral_Harbour" | "America/Cordoba" | "America/Costa_Rica" | "America/Creston" | "America/Cuiaba" | "America/Curacao" | "America/Danmarkshavn" | "America/Dawson" | "America/Dawson_Creek" | "America/Denver" | "America/Detroit" | "America/Dominica" | "America/Edmonton" | "America/Eirunepe" | "America/El_Salvador" | "America/Fort_Nelson" | "America/Fortaleza" | "America/Glace_Bay" | "America/Godthab" | "America/Goose_Bay" | "America/Grand_Turk" | "America/Grenada" | "America/Guadeloupe" | "America/Guatemala" | "America/Guayaquil" | "America/Guyana" | "America/Halifax" | "America/Havana" | "America/Hermosillo" | "America/Indiana/Indianapolis" | "America/Indiana/Knox" | "America/Indiana/Marengo" | "America/Indiana/Petersburg" | "America/Indiana/Tell_City" | "America/Indiana/Vevay" | "America/Indiana/Vincennes" | "America/Indiana/Winamac" | "America/Indianapolis" | "America/Inuvik" | "America/Iqaluit" | "America/Jamaica" | "America/Jujuy" | "America/Juneau" | "America/Kentucky/Louisville" | "America/Kentucky/Monticello" | "America/Kralendijk" | "America/La_Paz" | "America/Lima" | "America/Los_Angeles" | "America/Louisville" | "America/Lower_Princes" | "America/Maceio" | "America/Managua" | "America/Manaus" | "America/Marigot" | "America/Martinique" | "America/Matamoros" | "America/Mazatlan" | "America/Mendoza" | "America/Menominee" | "America/Merida" | "America/Metlakatla" | "America/Mexico_City" | "America/Miquelon" | "America/Moncton" | "America/Monterrey" | "America/Montevideo" | "America/Montserrat" | "America/Nassau" | "America/New_York" | "America/Nipigon" | "America/Nome" | "America/Noronha" | "America/North_Dakota/Beulah" | "America/North_Dakota/Center" | "America/North_Dakota/New_Salem" | "America/Nuuk" | "America/Ojinaga" | "America/Panama" | "America/Pangnirtung" | "America/Paramaribo" | "America/Phoenix" | "America/Port-au-Prince" | "America/Port_of_Spain" | "America/Porto_Velho" | "America/Puerto_Rico" | "America/Punta_Arenas" | "America/Rainy_River" | "America/Rankin_Inlet" | "America/Recife" | "America/Regina" | "America/Resolute" | "America/Rio_Branco" | "America/Santa_Isabel" | "America/Santarem" | "America/Santiago" | "America/Santo_Domingo" | "America/Sao_Paulo" | "America/Scoresbysund" | "America/Sitka" | "America/St_Barthelemy" | "America/St_Johns" | "America/St_Kitts" | "America/St_Lucia" | "America/St_Thomas" | "America/St_Vincent" | "America/Swift_Current" | "America/Tegucigalpa" | "America/Thule" | "America/Thunder_Bay" | "America/Tijuana" | "America/Toronto" | "America/Tortola" | "America/Vancouver" | "America/Whitehorse" | "America/Winnipeg" | "America/Yakutat" | "America/Yellowknife" | "Antarctica/Casey" | "Antarctica/Davis" | "Antarctica/DumontDUrville" | "Antarctica/Macquarie" | "Antarctica/Mawson" | "Antarctica/McMurdo" | "Antarctica/Palmer" | "Antarctica/Rothera" | "Antarctica/Syowa" | "Antarctica/Troll" | "Antarctica/Vostok" | "Arctic/Longyearbyen" | "Asia/Aden" | "Asia/Almaty" | "Asia/Amman" | "Asia/Anadyr" | "Asia/Aqtau" | "Asia/Aqtobe" | "Asia/Ashgabat" | "Asia/Atyrau" | "Asia/Baghdad" | "Asia/Bahrain" | "Asia/Baku" | "Asia/Bangkok" | "Asia/Barnaul" | "Asia/Beirut" | "Asia/Bishkek" | "Asia/Brunei" | "Asia/Calcutta" | "Asia/Chita" | "Asia/Choibalsan" | "Asia/Chongqing" | "Asia/Colombo" | "Asia/Damascus" | "Asia/Dhaka" | "Asia/Dili" | "Asia/Dubai" | "Asia/Dushanbe" | "Asia/Famagusta" | "Asia/Gaza" | "Asia/Hebron" | "Asia/Ho_Chi_Minh" | "Asia/Hong_Kong" | "Asia/Hovd" | "Asia/Irkutsk" | "Asia/Jakarta" | "Asia/Jayapura" | "Asia/Jerusalem" | "Asia/Kabul" | "Asia/Kamchatka" | "Asia/Karachi" | "Asia/Kathmandu" | "Asia/Katmandu" | "Asia/Khandyga" | "Asia/Kolkata" | "Asia/Krasnoyarsk" | "Asia/Kuala_Lumpur" | "Asia/Kuching" | "Asia/Kuwait" | "Asia/Macau" | "Asia/Magadan" | "Asia/Makassar" | "Asia/Manila" | "Asia/Muscat" | "Asia/Nicosia" | "Asia/Novokuznetsk" | "Asia/Novosibirsk" | "Asia/Omsk" | "Asia/Oral" | "Asia/Phnom_Penh" | "Asia/Pontianak" | "Asia/Pyongyang" | "Asia/Qatar" | "Asia/Qostanay" | "Asia/Qyzylorda" | "Asia/Rangoon" | "Asia/Riyadh" | "Asia/Saigon" | "Asia/Sakhalin" | "Asia/Samarkand" | "Asia/Seoul" | "Asia/Shanghai" | "Asia/Singapore" | "Asia/Srednekolymsk" | "Asia/Taipei" | "Asia/Tashkent" | "Asia/Tbilisi" | "Asia/Tehran" | "Asia/Thimphu" | "Asia/Tokyo" | "Asia/Tomsk" | "Asia/Ulaanbaatar" | "Asia/Urumqi" | "Asia/Ust-Nera" | "Asia/Vientiane" | "Asia/Vladivostok" | "Asia/Yakutsk" | "Asia/Yangon" | "Asia/Yekaterinburg" | "Asia/Yerevan" | "Atlantic/Azores" | "Atlantic/Bermuda" | "Atlantic/Canary" | "Atlantic/Cape_Verde" | "Atlantic/Faeroe" | "Atlantic/Faroe" | "Atlantic/Madeira" | "Atlantic/Reykjavik" | "Atlantic/South_Georgia" | "Atlantic/St_Helena" | "Atlantic/Stanley" | "Australia/Adelaide" | "Australia/Brisbane" | "Australia/Broken_Hill" | "Australia/Canberra" | "Australia/Currie" | "Australia/Darwin" | "Australia/Eucla" | "Australia/Hobart" | "Australia/Lindeman" | "Australia/Lord_Howe" | "Australia/Melbourne" | "Australia/Perth" | "Australia/Sydney" | "Etc/GMT" | "Etc/GMT+1" | "Etc/GMT+10" | "Etc/GMT+11" | "Etc/GMT+12" | "Etc/GMT+2" | "Etc/GMT+3" | "Etc/GMT+4" | "Etc/GMT+5" | "Etc/GMT+6" | "Etc/GMT+7" | "Etc/GMT+8" | "Etc/GMT+9" | "Etc/GMT-1" | "Etc/GMT-10" | "Etc/GMT-11" | "Etc/GMT-12" | "Etc/GMT-13" | "Etc/GMT-14" | "Etc/GMT-2" | "Etc/GMT-3" | "Etc/GMT-4" | "Etc/GMT-5" | "Etc/GMT-6" | "Etc/GMT-7" | "Etc/GMT-8" | "Etc/GMT-9" | "Etc/UTC" | "Europe/Amsterdam" | "Europe/Andorra" | "Europe/Astrakhan" | "Europe/Athens" | "Europe/Belgrade" | "Europe/Berlin" | "Europe/Bratislava" | "Europe/Brussels" | "Europe/Bucharest" | "Europe/Budapest" | "Europe/Busingen" | "Europe/Chisinau" | "Europe/Copenhagen" | "Europe/Dublin" | "Europe/Gibraltar" | "Europe/Guernsey" | "Europe/Helsinki" | "Europe/Isle_of_Man" | "Europe/Istanbul" | "Europe/Jersey" | "Europe/Kaliningrad" | "Europe/Kiev" | "Europe/Kirov" | "Europe/Kyiv" | "Europe/Lisbon" | "Europe/Ljubljana" | "Europe/London" | "Europe/Luxembourg" | "Europe/Madrid" | "Europe/Malta" | "Europe/Mariehamn" | "Europe/Minsk" | "Europe/Monaco" | "Europe/Moscow" | "Europe/Oslo" | "Europe/Paris" | "Europe/Podgorica" | "Europe/Prague" | "Europe/Riga" | "Europe/Rome" | "Europe/Samara" | "Europe/San_Marino" | "Europe/Sarajevo" | "Europe/Saratov" | "Europe/Simferopol" | "Europe/Skopje" | "Europe/Sofia" | "Europe/Stockholm" | "Europe/Tallinn" | "Europe/Tirane" | "Europe/Ulyanovsk" | "Europe/Uzhgorod" | "Europe/Vaduz" | "Europe/Vatican" | "Europe/Vienna" | "Europe/Vilnius" | "Europe/Volgograd" | "Europe/Warsaw" | "Europe/Zagreb" | "Europe/Zaporozhye" | "Europe/Zurich" | "Indian/Antananarivo" | "Indian/Chagos" | "Indian/Christmas" | "Indian/Cocos" | "Indian/Comoro" | "Indian/Kerguelen" | "Indian/Mahe" | "Indian/Maldives" | "Indian/Mauritius" | "Indian/Mayotte" | "Indian/Reunion" | "Pacific/Apia" | "Pacific/Auckland" | "Pacific/Bougainville" | "Pacific/Chatham" | "Pacific/Chuuk" | "Pacific/Easter" | "Pacific/Efate" | "Pacific/Enderbury" | "Pacific/Fakaofo" | "Pacific/Fiji" | "Pacific/Funafuti" | "Pacific/Galapagos" | "Pacific/Gambier" | "Pacific/Guadalcanal" | "Pacific/Guam" | "Pacific/Honolulu" | "Pacific/Johnston" | "Pacific/Kanton" | "Pacific/Kiritimati" | "Pacific/Kosrae" | "Pacific/Kwajalein" | "Pacific/Majuro" | "Pacific/Marquesas" | "Pacific/Midway" | "Pacific/Nauru" | "Pacific/Niue" | "Pacific/Norfolk" | "Pacific/Noumea" | "Pacific/Pago_Pago" | "Pacific/Palau" | "Pacific/Pitcairn" | "Pacific/Pohnpei" | "Pacific/Ponape" | "Pacific/Port_Moresby" | "Pacific/Rarotonga" | "Pacific/Saipan" | "Pacific/Tahiti" | "Pacific/Tarawa" | "Pacific/Tongatapu" | "Pacific/Truk" | "Pacific/Wake" | "Pacific/Wallis";
@@ -1,115 +0,0 @@
1
- import { type ClientChannel } from "ssh2";
2
- import type { Console, Device } from "../schema/index.js";
3
- /** An open console: the stream to the device's CLI, and how to let it go. `close` waits for the console to go quiet, then lets the port go. */
4
- export type ConsoleSession = {
5
- channel: ClientChannel;
6
- close: () => Promise<void>;
7
- };
8
- /** How a platform's console asks for a login and shows its prompt, and what moves it on from anywhere else. */
9
- export type ConsoleDialect = {
10
- /** The login prompt. */
11
- login: RegExp;
12
- /** The password prompt. */
13
- password: RegExp;
14
- /** The CLI's prompt once logged in. */
15
- prompt: RegExp;
16
- /** What logs out from the prompt. */
17
- logout: string;
18
- /** Other places a console can be left, each with what moves it toward a login prompt: a pager, a config level, a question. Checked before the prompt. */
19
- others?: readonly (readonly [RegExp, string])[];
20
- /** The name typed at the login prompt, when the platform adds to it. */
21
- user?: (user: string) => string;
22
- /** What the console prints when it refuses a password, for a console that then shows no login prompt. */
23
- refused?: RegExp;
24
- };
25
- /** The channel a console speaks on: an SSH stream from the relay, or anything shaped like one. */
26
- type Channel = Pick<ClientChannel, "write"> & {
27
- on(event: "data", listener: (chunk: Buffer) => void): unknown;
28
- removeListener(event: "data", listener: (chunk: Buffer) => void): unknown;
29
- };
30
- export declare class SerialConsole {
31
- private static readonly RELAY_PATH;
32
- /** A serial port the relay is started with: a path under /dev, which reaches a shell, or a Windows COM port. */
33
- private static readonly PORT;
34
- private static readonly WINDOWS_PORT;
35
- /** Terminal escape sequences: cursor moves, screen clears, character sets and modes. */
36
- private static readonly ESCAPES;
37
- /** A session to a jump host, through `cloudflared access ssh` when it sits behind a Cloudflare Tunnel. */
38
- private static connectJump;
39
- /**
40
- * Open a device's serial console, through its jump host or on this computer.
41
- *
42
- * A port another program holds is tried again every five seconds, `attempts` times in all, then fails with a message that starts with `busy:`.
43
- */
44
- static open(console: Console, attempts?: number): Promise<ConsoleSession>;
45
- private static openOnJump;
46
- /** The relay as a child process: Python on Linux and macOS, PowerShell on Windows. */
47
- private static openHere;
48
- /** Wait until the relay says it holds the port, or why it cannot. */
49
- private static relayReady;
50
- /** A terminal ends a line with a carriage return. Adapters write lines as they do over SSH, and the console gets what a keyboard would send. */
51
- private static asTerminal;
52
- /** A device's console and its login, for `--console`. */
53
- static of(device: Device): {
54
- console: Console;
55
- user: string;
56
- password: string;
57
- };
58
- /**
59
- * Write, then wait until what the console printed since ends with one of the patterns. Returns which, and what was printed.
60
- *
61
- * With `settle`, a match counts only once nothing more arrives for that many milliseconds, so a line in the middle of the output that looks like a prompt does not end it.
62
- */
63
- static expect(channel: Channel, write: string, patterns: readonly RegExp[], timeout?: number, settle?: number): Promise<{
64
- index: number;
65
- text: string;
66
- }>;
67
- /**
68
- * Log in on a console, whatever state the last session left it in: what `others` names is moved on, a session left open is logged out, so every session starts from a fresh login. Returns once the CLI's prompt shows. A console that asks only for a password (`passwordOnly`) is logged in at its password prompt, with no name typed.
69
- */
70
- static login(channel: Channel, dialect: ConsoleDialect, user: string, password: string, passwordOnly?: boolean): Promise<void>;
71
- /** Wait until the console has printed nothing for `silence` milliseconds, dropping what it printed, at most five seconds. */
72
- private static quiet;
73
- /** Write, then collect what the console prints until it is quiet for `silence` milliseconds, or for `limit` in all. Carriage returns and escape sequences are dropped. */
74
- static listen(channel: Channel, write: string, silence: number, limit?: number): Promise<string>;
75
- /** The text after a command's echo. A terminal wraps a long echo where it likes, so the echo is matched character by character, line breaks it added skipped. */
76
- static afterEcho(text: string, command: string): string;
77
- /** Where the echo of a command that starts at `start` ends, or undefined when the text there is not its echo. */
78
- private static echoEnd;
79
- }
80
- /** A CLI on a console or in an SSH shell that runs one command at a time and returns what it printed, as an SSH exec would: no echo, no prompt. */
81
- export declare class ConsoleShell {
82
- private readonly channel;
83
- private readonly dialect;
84
- /** Milliseconds of quiet after the prompt shows before a command counts as done. */
85
- private readonly settle;
86
- /** The quiet to wait for after the prompt when output can hold a line that looks like it, as `circuit show` prints whatever the device has. */
87
- static readonly SETTLE = 1000;
88
- constructor(channel: Channel, dialect: ConsoleDialect,
89
- /** Milliseconds of quiet after the prompt shows before a command counts as done. */
90
- settle?: number);
91
- /** Run a command and wait for the prompt. A pager in `others` is answered as it shows. */
92
- run(command: string, timeout?: number): Promise<string>;
93
- /** Log out, so no session is left open on the console. */
94
- logout(): void;
95
- }
96
- /** One line for `circuit console`: what to send, the quiet that ends its answer, and the text the last answer must end with for the line to be sent. */
97
- export type ScriptLine = {
98
- text: string;
99
- quiet: number;
100
- onlyAfter?: string;
101
- };
102
- /**
103
- * Lines sent to a console one at a time, each answer read until the console goes quiet, as a person would type them.
104
- *
105
- * A line may start with `@if=TEXT=>`: it is sent only when the last answer ends with TEXT, for a prompt that may or may not come. Then, or alone, `@wait=N:` waits for N seconds of quiet instead of the usual 1.5, for a slow command.
106
- */
107
- export declare class ConsoleScript {
108
- /** The quiet that ends an answer, in milliseconds. */
109
- static readonly QUIET = 1500;
110
- /** A line as written, with `quiet` for a line that has no `@wait=`. */
111
- static parse(line: string, quiet?: number): ScriptLine;
112
- /** Send each line and hand each answer to `answered` as it comes. A line whose condition does not hold is skipped. */
113
- static run(channel: Channel, lines: readonly string[], answered: (answer: string) => void, quiet?: number): Promise<void>;
114
- }
115
- export {};
@@ -1,32 +0,0 @@
1
- /** What the pings found: how many were sent, and the round trip of each that came back, in milliseconds. */
2
- export type PathMeasure = {
3
- sent: number;
4
- times: number[];
5
- };
6
- /** Whether an apply may go ahead over the path, and a line that says why. */
7
- export type PathVerdict = {
8
- refuse: boolean;
9
- summary: string;
10
- };
11
- export declare class PathCheck {
12
- /** Pings sent in all. With 20, one lost is 5%. */
13
- static readonly PINGS = 20;
14
- /** Ping programs run side by side, so the check takes about five seconds on every system: each sends one ping a second. */
15
- private static readonly RUNS;
16
- /** The most loss allowed, in percent: one of 20 pings may be lost, two may not. */
17
- static readonly MAX_LOSS_PERCENT = 5;
18
- /** The highest average round trip allowed, in milliseconds. */
19
- static readonly MAX_AVERAGE_MS = 300;
20
- /** How long one ping program may run before it is stopped and what it printed is counted. */
21
- private static readonly LIMIT_MS;
22
- /**
23
- * The round trip of every reply in what `ping` printed, in milliseconds. A reply is the one line with a time after `=` or `<` and before `ms`, as in `time=12 ms` or `time<1ms`: the same in every language `ping` prints in. A summary line has several times, or none right before `ms`, and is not counted.
24
- */
25
- static parse(output: string): number[];
26
- /** Whether the path is good enough to apply over. A device that answers no ping at all may only block it, so that alone is not refused. */
27
- static verdict(host: string, measure: PathMeasure): PathVerdict;
28
- /** Ping a host with the system's `ping`. Undefined when there is no `ping` to run. */
29
- static measure(host: string): Promise<PathMeasure | undefined>;
30
- /** What one run of `ping` printed. Windows takes `-n` and a wait per ping in milliseconds; Linux and macOS take `-c`, and macOS pings IPv6 with `ping6`. */
31
- private static ping;
32
- }