@takodotid/circuit 0.39.0 → 0.41.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.
@@ -2,7 +2,7 @@ import type { IP, Secret } from "./common";
2
2
  import type { AclRule, Firewall } from "./firewall";
3
3
  import type { Interface, Port, Vlan } from "./interfaces";
4
4
  import type { PrefixSet, RoutePolicy } from "./policy";
5
- import type { Routing } from "./routing";
5
+ import type { Routing, StaticRoute } from "./routing";
6
6
  import type { Certificate, DhcpRelay, DhcpServer, FlowExport, Management, System, User } from "./system";
7
7
 
8
8
  /** How the framework reaches the device. */
@@ -43,6 +43,25 @@ export type Console = {
43
43
  passwordOnly?: true;
44
44
  };
45
45
 
46
+ /**
47
+ * Virtual domains, on FortiOS: the device's own traffic kept apart from the traffic it routes. Everything is in `root` when absent.
48
+ *
49
+ * Multi-VDOM mode is turned on by hand, not by a plan: it moves the whole configuration into `root` and ends every session.
50
+ */
51
+ export type Vdoms<I extends string> = {
52
+ /**
53
+ * A VDOM for the device's own traffic: FortiGuard, NTP, DNS and logging leave from it, by its own routes, so they never follow the routed traffic's default route. Everything not listed here stays in `root`.
54
+ */
55
+ management: {
56
+ /** Its name, such as `mgmt`. Not `root`. */
57
+ name: string;
58
+ /** The ports and interfaces in it, by name. A LAG's member ports go with the LAG. */
59
+ interfaces: readonly I[];
60
+ /** Its static routes, such as its own default route. */
61
+ static?: readonly StaticRoute<I, never>[];
62
+ };
63
+ };
64
+
46
65
  /** A separate routing table, with the interfaces that route in it. */
47
66
  export type Vrf = {
48
67
  /** What the VRF is for. */
@@ -120,4 +139,6 @@ export type Device<
120
139
  };
121
140
  /** Forward in hardware where the platform can. An interface may override it. */
122
141
  hardware_offload?: boolean;
142
+ /** Virtual domains, on FortiOS only: a management VDOM apart from the routed traffic. */
143
+ vdoms?: Vdoms<NoInfer<I | N>>;
123
144
  };
@@ -104,7 +104,11 @@ export type Firewall<I extends string, AS extends string> = {
104
104
  };
105
105
  /** Helpers that run. None when absent. */
106
106
  helpers?: readonly Helper[];
107
- /** Traffic to and from these prefixes passes without connection tracking. A flood toward them cannot fill the connection table, and rules see its packets in the state `untracked`. Everything is tracked when absent. */
107
+ /**
108
+ * Traffic to and from these prefixes passes without connection tracking. A flood toward them cannot fill the connection table, and rules see its packets in the state `untracked`. Everything is tracked when absent.
109
+ *
110
+ * Each address NAT uses inside one of these prefixes (a source translation's `to`, a destination translation's `to` or matched `dst`) stays tracked: Circuit writes two accept rules for it, one for traffic to it and one for traffic from it, before the untracked rules. Without them, a reply to that address would skip tracking and never be translated back.
111
+ */
108
112
  untracked?: readonly Prefix[];
109
113
  };
110
114
 
@@ -83,15 +83,23 @@ export type Sets = {
83
83
  };
84
84
 
85
85
  /**
86
- * One step of a route policy. Evaluated in this order: `call`, then `match`, then `set`, then `action`.
87
- *
88
- * A rule without `action` changes the route and moves on to the next rule.
86
+ * 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.
89
87
  */
90
- export type PolicyRule<P extends string, S extends string> = {
88
+ export type CallRule<P extends string> = {
91
89
  /** Shown beside the rule on the device. */
92
90
  description?: string;
93
- /** Evaluate another policy first. A route it accepts or rejects stops there. */
94
- call?: P;
91
+ /** The policy to run. */
92
+ call: P;
93
+ match?: never;
94
+ set?: never;
95
+ action?: never;
96
+ };
97
+
98
+ /** Change and decide on the routes that match. A rule without `action` changes the route and moves on to the next rule. */
99
+ export type MatchRule<S extends string> = {
100
+ /** Shown beside the rule on the device. */
101
+ description?: string;
102
+ call?: never;
95
103
  /** Which routes the rule applies to. Every route when absent. */
96
104
  match?: Match<S>;
97
105
  /** What to change on a matching route. */
@@ -100,5 +108,8 @@ export type PolicyRule<P extends string, S extends string> = {
100
108
  action?: "accept" | "reject";
101
109
  };
102
110
 
111
+ /** One step of a route policy: a call to another policy, or a rule that matches routes, changes them and may decide on them. */
112
+ export type PolicyRule<P extends string, S extends string> = CallRule<P> | MatchRule<S>;
113
+
103
114
  /** Rules evaluated in order, first decision wins. A route no rule accepts is rejected. */
104
115
  export type RoutePolicy<P extends string, S extends string> = readonly PolicyRule<P, S>[];