UNPKG

1.25 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const log_1 = require("../common/log");
4const log = log_1.create('dragon');
5const relation_1 = require("./relation");
6function canDragonFilter(routingTable, getRelation, prefix, route) {
7 for (const parentPrefix of routingTable.getKeysPrefixesOf(prefix)) {
8 const parentRouteUpdate = routingTable.get(parentPrefix);
9 if (!parentRouteUpdate || !parentRouteUpdate.route) {
10 log.warn('found a parent prefix, but no parent route; this should never happen. prefix=%s parentPrefix=%s', prefix, parentPrefix);
11 continue;
12 }
13 const parentRoute = parentRouteUpdate.route;
14 if (parentRoute.nextHop === '') {
15 continue;
16 }
17 const parentRelation = getRelation(parentRoute.nextHop);
18 const childRelation = getRelation(route.nextHop);
19 if (relation_1.getRelationPriority(parentRelation) < relation_1.getRelationPriority(childRelation)) {
20 continue;
21 }
22 log.trace('applied DRAGON route filter. prefix=%s parentPrefix=%s', prefix, parentPrefix);
23 return true;
24 }
25 return false;
26}
27exports.canDragonFilter = canDragonFilter;
28//# sourceMappingURL=dragon.js.map
\No newline at end of file