mirror of
https://github.com/nttgin/BGPalerter.git
synced 2024-05-19 06:50:08 +00:00
small fix to showPaths option + option to detect disconnections in ris
This commit is contained in:
@@ -107,10 +107,12 @@ export default class ConnectorFactory {
|
||||
resolve(true);
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error) {
|
||||
env.logger.log({
|
||||
level: 'error',
|
||||
message: error
|
||||
});
|
||||
}
|
||||
resolve(false);
|
||||
})
|
||||
}))));
|
||||
|
||||
@@ -72,6 +72,9 @@ export default class ConnectorRIS extends Connector{
|
||||
};
|
||||
|
||||
_openConnect = (resolve) => {
|
||||
if (this.connectionFailedTimer) {
|
||||
clearTimeout(this.connectionFailedTimer);
|
||||
}
|
||||
resolve(true);
|
||||
this._connect(this.name + ' connector connected');
|
||||
};
|
||||
@@ -87,8 +90,18 @@ export default class ConnectorRIS extends Connector{
|
||||
perMessageDeflate: this.params.perMessageDeflate
|
||||
});
|
||||
|
||||
this.connectionFailedTimer = setTimeout(() => {
|
||||
this.ws.terminate();
|
||||
this.ws.removeAllListeners();
|
||||
this.connect();
|
||||
reject("RIPE RIS connection failed. Trying again...");
|
||||
}, 20000);
|
||||
|
||||
this.ws.on('message', this._messageToJson);
|
||||
this.ws.on('close', (error) => {
|
||||
if (this.connectionFailedTimer) {
|
||||
clearTimeout(this.connectionFailedTimer);
|
||||
}
|
||||
this._close("RIPE RIS disconnected (error: " + error + "). Read more at https://github.com/nttgin/BGPalerter/blob/master/docs/ris-disconnections.md");
|
||||
});
|
||||
this.ws.on('error', this._error);
|
||||
|
||||
@@ -78,9 +78,11 @@ export default class Report {
|
||||
|
||||
let matched = null;
|
||||
let pathsCount = {};
|
||||
let sortedPathIndex = null;
|
||||
let sortedPathIndex;
|
||||
|
||||
if (this.params.showPaths > 0) {
|
||||
content.data
|
||||
.filter(i => !!i.matchedMessage && !!i.matchedMessage.path)
|
||||
.map(i => JSON.stringify(i.matchedMessage.path.getValues().slice(1)))
|
||||
.forEach(path => {
|
||||
if (!pathsCount[path]) {
|
||||
@@ -93,15 +95,17 @@ export default class Report {
|
||||
.map(key => [key, pathsCount[key]]);
|
||||
|
||||
sortedPathIndex.sort((first, second) => second[1] - first[1]);
|
||||
context.pathNumber = (this.params.showPaths > 0) ? Math.min(this.params.showPaths, sortedPathIndex.length) : "";
|
||||
context.paths = (this.params.showPaths > 0) ? sortedPathIndex
|
||||
context.pathNumber = Math.min(this.params.showPaths, sortedPathIndex.length);
|
||||
context.paths = sortedPathIndex
|
||||
.slice(0, this.params.showPaths)
|
||||
.map(i => i[0]).join("\n") : "Disabled";
|
||||
.map(i => i[0]).join("\n");
|
||||
} else {
|
||||
context.pathNumber = "";
|
||||
context.paths = "Disabled";
|
||||
}
|
||||
|
||||
switch(channel){
|
||||
case "hijack":
|
||||
|
||||
|
||||
matched = content.data[0].matchedRule;
|
||||
context.prefix = matched.prefix;
|
||||
context.description = matched.description;
|
||||
|
||||
Reference in New Issue
Block a user