@takodotid/circuit 0.10.0 → 0.11.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.
@@ -179,8 +179,8 @@ function communityScheme(scheme) {
179
179
  action: "accept"
180
180
  };
181
181
  };
182
- const actions = (neighborAs) => [
183
- ...scheme.blackhole !== undefined ? [
182
+ const actions = (neighborAs, options = {}) => [
183
+ ...scheme.blackhole !== undefined && !options.blackhole ? [
184
184
  {
185
185
  description: "Blackholed here, never announced",
186
186
  match: { large_community: community(scheme.blackhole, 0) },
@@ -199,6 +199,18 @@ function communityScheme(scheme) {
199
199
  action: "reject"
200
200
  }
201
201
  ] : [],
202
+ ...scheme.blackhole !== undefined && options.blackhole ? [
203
+ {
204
+ description: `Blackhole passed on to AS${neighborAs}`,
205
+ match: { large_community: community(scheme.blackhole, 0) },
206
+ set: {
207
+ remove_communities: ours.standard,
208
+ remove_large_communities: ours.large,
209
+ add_communities: [options.blackhole]
210
+ },
211
+ action: "accept"
212
+ }
213
+ ] : [],
202
214
  ...PREPENDS.flatMap(([name, times]) => {
203
215
  const fn = scheme.prepend?.[name];
204
216
  if (fn === undefined)
@@ -83,7 +83,7 @@ export type CommunityScheme<Class extends string = string> = {
83
83
  * 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.
84
84
  *
85
85
  * - `tag(neighborClass, neighborAs, { site, keepActions })`: a rule for an import policy. It removes your communities a neighbor set, then adds where the route was learned. `site` is needed when the scheme has `learned_at`. With `keepActions`, for a customer, its action communities stay.
86
- * - `actions(neighborAs)`: 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.
86
+ * - `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.
87
87
  * - `blackhole(prefixSet)`: a rule for a customer's import policy, before anything that rejects long prefixes. It takes a route the customer asked to blackhole, but only inside `prefixSet`, its own space, and drops traffic to it here.
88
88
  * - `catalogue`: every community, for `communities` in `defineNetwork`.
89
89
  */
@@ -93,7 +93,9 @@ export declare function communityScheme<const Class extends string>(scheme: Comm
93
93
  site?: number;
94
94
  keepActions?: boolean;
95
95
  }) => PolicyRule<never, never>;
96
- actions: (neighborAs: number) => PolicyRule<never, never>[];
96
+ actions: (neighborAs: number, options?: {
97
+ blackhole?: string;
98
+ }) => PolicyRule<never, never>[];
97
99
  blackhole: <S extends string>(prefixSet: S) => PolicyRule<never, S>;
98
100
  catalogue: Community[];
99
101
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takodotid/circuit",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Declarative, vendor-neutral network configuration: describe each device in TypeScript, and Circuit makes the device match. Alpha.",
5
5
  "keywords": [
6
6
  "network",
@@ -239,7 +239,7 @@ const article = (word: string) => (/^[aeiou]/i.test(word) ? `an ${word}` : `a ${
239
239
  * 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.
240
240
  *
241
241
  * - `tag(neighborClass, neighborAs, { site, keepActions })`: a rule for an import policy. It removes your communities a neighbor set, then adds where the route was learned. `site` is needed when the scheme has `learned_at`. With `keepActions`, for a customer, its action communities stay.
242
- * - `actions(neighborAs)`: 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.
242
+ * - `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.
243
243
  * - `blackhole(prefixSet)`: a rule for a customer's import policy, before anything that rejects long prefixes. It takes a route the customer asked to blackhole, but only inside `prefixSet`, its own space, and drops traffic to it here.
244
244
  * - `catalogue`: every community, for `communities` in `defineNetwork`.
245
245
  */
@@ -286,8 +286,8 @@ export function communityScheme<const Class extends string>(scheme: CommunitySch
286
286
  };
287
287
  };
288
288
 
289
- const actions = (neighborAs: number): PolicyRule<never, never>[] => [
290
- ...(scheme.blackhole !== undefined
289
+ const actions = (neighborAs: number, options: { blackhole?: string } = {}): PolicyRule<never, never>[] => [
290
+ ...(scheme.blackhole !== undefined && !options.blackhole
291
291
  ? [
292
292
  {
293
293
  description: "Blackholed here, never announced",
@@ -310,6 +310,20 @@ export function communityScheme<const Class extends string>(scheme: CommunitySch
310
310
  },
311
311
  ]
312
312
  : []),
313
+ ...(scheme.blackhole !== undefined && options.blackhole
314
+ ? [
315
+ {
316
+ description: `Blackhole passed on to AS${neighborAs}`,
317
+ match: { large_community: community(scheme.blackhole, 0) },
318
+ set: {
319
+ remove_communities: ours.standard,
320
+ remove_large_communities: ours.large,
321
+ add_communities: [options.blackhole],
322
+ },
323
+ action: "accept" as const,
324
+ },
325
+ ]
326
+ : []),
313
327
  ...PREPENDS.flatMap(([name, times]) => {
314
328
  const fn = scheme.prepend?.[name];
315
329
  if (fn === undefined) return [];