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

fix only last array item considered for ASN monitoring (#404)

This commit is contained in:
Massimo Candela
2020-11-21 16:31:35 +01:00
parent ffbb33c6fc
commit 3bf6fcc8b9
3 changed files with 9 additions and 7 deletions

View File

@@ -42,12 +42,14 @@ export default class InputYml extends Input {
super(env);
this.prefixes = [];
this.asns = [];
this.options = {};
this.watcherSet = false;
if (!this.config.monitoredPrefixesFiles || this.config.monitoredPrefixesFiles.length === 0) {
throw new Error("The monitoredPrefixesFiles key is missing in the config file");
} else if (this.config.monitoredPrefixesFiles.length === 1) {
this.setReGeneratePrefixList();
}
this.watcherSet = false;
};
loadPrefixes = () => {
@@ -115,10 +117,10 @@ export default class InputYml extends Input {
if (this.validate(monitoredPrefixesFile)) {
if (monitoredPrefixesFile.options) {
this.options = monitoredPrefixesFile.options;
this.options = Object.assign(this.options, monitoredPrefixesFile.options);
if (monitoredPrefixesFile.options.monitorASns) {
this.asns = Object
const newAsnSet = Object
.keys(monitoredPrefixesFile.options.monitorASns)
.map(asn => {
if (uniqueAsns[asn]) {
@@ -131,6 +133,8 @@ export default class InputYml extends Input {
group: 'default'
}, monitoredPrefixesFile.options.monitorASns[asn]);
});
this.asns = this.asns.concat(newAsnSet);
}
}
@@ -323,7 +327,6 @@ export default class InputYml extends Input {
if (rule.includeMonitors.length) prefixes[prefix].includeMonitors = rule.includeMonitors;
}
const monitorASns = {};
for (let asnRule of this.asns) {
monitorASns[asnRule.asn.getValue()] = {