1
0
mirror of https://github.com/nttgin/BGPalerter.git synced 2024-05-19 06:50:08 +00:00

added subscription optimisation to avoid server side filtering

This commit is contained in:
Massimo Candela
2020-01-20 17:56:43 +01:00
parent ce5695b14f
commit 9369b82633
2 changed files with 16 additions and 2 deletions

View File

@@ -55,7 +55,21 @@ export default class Input {
return false;
};
sanitizePrefixList = () => {
this.prefixes.forEach(item => {
if (item.prefix.includes(':')){
item.prefix = ipUtils.expandIPv6(item.prefix);
}
});
if ([...new Set(this.prefixes.map(i => i.prefix))].length !== this.prefixes.length) {
throw new Error("The prefix list contains duplicates");
}
};
getMonitoredLessSpecifics = () => {
this.sanitizePrefixList();
if (!this.prefixes.length) {
return [];
}
@@ -68,7 +82,6 @@ export default class Input {
lessSpecifics.push(prefixes[prefixes.length - 1]);
for (let p1 of prefixes.slice(0, -1)) {
if (!this._isAlreadyContained(p1.prefix, lessSpecifics)){
lessSpecifics.push(p1);
@@ -87,6 +100,7 @@ export default class Input {
};
getMoreSpecificMatch = (prefix) => {
this.sanitizePrefixList();
for (let p of this.prefixes) {
if (p.prefix === prefix) {

View File

@@ -34,7 +34,7 @@ import yaml from "js-yaml";
import fs from "fs";
import Input from "./input";
import ipUtils from "ip-sub";
import { AS, Path } from "../model";
import { AS } from "../model";
export default class InputYml extends Input {