mirror of
https://github.com/nttgin/BGPalerter.git
synced 2024-05-19 06:50:08 +00:00
fixed prefix sorting side effect affecting more specific matching after less specific search
This commit is contained in:
@@ -61,20 +61,16 @@ export default class Input {
|
||||
return [];
|
||||
}
|
||||
|
||||
const prefixes = this.prefixes.sort((a, b) => {
|
||||
return ipUtils.sortByPrefixLength(a.prefix, b.prefix);
|
||||
});
|
||||
|
||||
const lessSpecifics = [];
|
||||
|
||||
let prefixes = this.prefixes;
|
||||
lessSpecifics.push(prefixes[prefixes.length - 1]);
|
||||
|
||||
for (let p1 of prefixes.slice(0, -1)) {
|
||||
for (let n=prefixes.length - 2; n>=0; n--) {
|
||||
const p1 = prefixes[n];
|
||||
if (!this._isAlreadyContained(p1.prefix, lessSpecifics)){
|
||||
lessSpecifics.push(p1);
|
||||
}
|
||||
}
|
||||
|
||||
return lessSpecifics;
|
||||
};
|
||||
|
||||
|
@@ -113,7 +113,7 @@ export default class InputYml extends Input {
|
||||
}
|
||||
}
|
||||
|
||||
this.prefixes = this.prefixes.sort((a, b) => {
|
||||
this.prefixes.sort((a, b) => {
|
||||
return ipUtils.sortByPrefixLength(b.prefix, a.prefix);
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user