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

fixed some important stability issues

This commit is contained in:
Massimo Candela
2019-10-04 21:03:51 +02:00
parent 96d754c1ed
commit 7a0c0581c0
4 changed files with 22 additions and 6 deletions

View File

@@ -164,6 +164,9 @@ export default class ConnectorRIS extends Connector{
if (message["path"] && message["path"].length) {
path = new Path(message["path"].map(i => new AS(i)));
originAS = path.getLast();
} else {
path = new Path([]);
originAS = null;
}
for (let announcement of announcements) {

View File

@@ -120,6 +120,7 @@ module.exports = function generatePrefixes(asns, outputFile, exclude, excludeDel
return Promise.all(list.map(i => generateRule(i.prefix, asn, false, null, false)))
.then(() => list.map(i => i.prefix))
})
};
const validatePrefix = (asn, prefix) => {
@@ -148,7 +149,6 @@ module.exports = function generatePrefixes(asns, outputFile, exclude, excludeDel
} else {
someNotValidatedPrefixes = true;
}
})
};
@@ -159,11 +159,20 @@ module.exports = function generatePrefixes(asns, outputFile, exclude, excludeDel
return batchPromises(20, prefixes, prefix => {
return getAnnouncedMoreSpecifics(prefix)
.then((items) => Promise
.all(items.map(item => generateRule(item.prefix, item.asn, true, item.description, excludeDelegated))));
.all(items.map(item => generateRule(item.prefix, item.asn, true, item.description, excludeDelegated))))
.catch((e) => {
console.log("Cannot download more specific prefixes of", prefix, e);
})
})
.catch((e) => {
console.log("Cannot download more specific prefixes", e);
})
})
.then(() => {
return Promise.all(Object.keys(generateList).map(prefix => validatePrefix(generateList[prefix].asn[0], prefix)))
.catch((e) => {
console.log("ROA check failed due to error", e);
})
})
.then(() => {
const yamlContent = yaml.dump(generateList);
@@ -173,6 +182,9 @@ module.exports = function generatePrefixes(asns, outputFile, exclude, excludeDel
console.log("WARNING: The generated configuration is a snapshot of what is currently announced by " + asns + " but some of the prefixes don't have ROA objects associated. Please, verify the config file by hand!");
}
console.log("Done!");
});
})
.catch((e) => {
console.log("Something went wrong", e);
})
}
};

View File

@@ -61,10 +61,10 @@ export default class Input {
const lessSpecifics = [];
lessSpecifics.push(prefixes.pop());
lessSpecifics.push(prefixes[prefixes.length - 1]);
for (let p1 of prefixes) {
for (let p1 of prefixes.slice(0, -1)) {
if (!this._isAlreadyContained(p1.prefix, lessSpecifics)){
lessSpecifics.push(p1);
}

View File

@@ -49,6 +49,7 @@ export default class MonitorPath extends Monitor {
};
squashAlerts = (alerts) => {
alerts = alerts.filter(i => i.matchedRule && i.matchedRule.path);
const lengthViolation = (alerts.some(i => i.extra.lengthViolation)) ? "(including length violation) " : "";
return `Matched ${alerts[0].matchedRule.path.matchDescription} on prefix ${alerts[0].matchedMessage.prefix} ${lengthViolation}${alerts.length} times.`;
};