Skip to content

Commit

Permalink
new dist
Browse files Browse the repository at this point in the history
  • Loading branch information
massimocandela committed Jan 6, 2025
1 parent d214138 commit d77711a
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 74 deletions.
34 changes: 17 additions & 17 deletions dist/src/connectors/connectorRIS.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,22 @@ var ConnectorRIS = exports["default"] = /*#__PURE__*/function (_Connector) {
});
_defineProperty(_this, "_appendListeners", function (resolve, reject) {
if (_this._shouldCanaryMonitoringStart()) {
_this.ws.on('message', _this._messageToJsonCanary);
_this.ws.on("message", _this._messageToJsonCanary);
} else {
_this.ws.on('message', _this._messageToJson);
_this.ws.on("message", _this._messageToJson);
}
_this.ws.on('close', function (error) {
_this.ws.on("close", function (error) {
if (_this.connected) {
_this._disconnect("RIPE RIS disconnected (error: " + error + "). Read more at https://github.com/nttgin/BGPalerter/blob/main/docs/ris-disconnections.md");
} else {
_this._disconnect("It was not possible to establish a connection with RIPE RIS");
reject();
}
});
_this.ws.on('error', function (error) {
_this.ws.on("error", function (error) {
_this._error("".concat(_this.name, " ").concat(error.message, " (instance:").concat(_this.instanceId, " connection:").concat(error.connection, ")"));
});
_this.ws.on('open', function (data) {
_this.ws.on("open", function (data) {
return _this._openConnect(resolve, data);
});
});
Expand Down Expand Up @@ -184,13 +184,13 @@ var ConnectorRIS = exports["default"] = /*#__PURE__*/function (_Connector) {
var params = JSON.parse(JSON.stringify(_this.params.subscription));
if (monitoredPrefixes.length > risLimitPrefixes) {
_this.logger.log({
level: 'error',
level: "error",
message: "Prefix list of abnormal length, truncated to 10000 to prevent RIS overload"
});
monitoredPrefixes = monitoredPrefixes.slice(0, risLimitPrefixes);
}
if (monitoredPrefixes.filter(function (i) {
return _ipSub["default"].isEqualPrefix(i.prefix, '0:0:0:0:0:0:0:0/0') || _ipSub["default"].isEqualPrefix(i.prefix, '0.0.0.0/0');
return _ipSub["default"].isEqualPrefix(i.prefix, "0:0:0:0:0:0:0:0/0") || _ipSub["default"].isEqualPrefix(i.prefix, "0.0.0.0/0");
}).length === 2) {
delete params.prefix;
if (!_this.subscribed["everything"]) {
Expand Down Expand Up @@ -231,7 +231,7 @@ var ConnectorRIS = exports["default"] = /*#__PURE__*/function (_Connector) {
var params = JSON.parse(JSON.stringify(_this.params.subscription));
if (monitoredASns.length > risLimitAses) {
_this.logger.log({
level: 'error',
level: "error",
message: "AS list of abnormal length, truncated to 10 to prevent RIS overload"
});
monitoredASns = monitoredASns.slice(0, risLimitAses);
Expand Down Expand Up @@ -279,12 +279,12 @@ var ConnectorRIS = exports["default"] = /*#__PURE__*/function (_Connector) {
}).then(function () {
_this._checkCanary();
_this.logger.log({
level: 'info',
level: "info",
message: "Subscribed to beacons"
});
})["catch"](function () {
_this.logger.log({
level: 'error',
level: "error",
message: "Failed to subscribe to beacons"
});
});
Expand All @@ -294,7 +294,7 @@ var ConnectorRIS = exports["default"] = /*#__PURE__*/function (_Connector) {
clearTimeout(_this._timerCheckCanary);
if (!_this.connected) {
_this.logger.log({
level: 'info',
level: "info",
message: "RIS connected again, the streaming session is working properly"
});
}
Expand All @@ -303,7 +303,7 @@ var ConnectorRIS = exports["default"] = /*#__PURE__*/function (_Connector) {
if (_this.connected) {
_this.connected = false;
_this.logger.log({
level: 'error',
level: "error",
message: "RIS has been silent for too long, probably there is something wrong"
});
}
Expand All @@ -317,13 +317,13 @@ var ConnectorRIS = exports["default"] = /*#__PURE__*/function (_Connector) {
return _this.subscribe(input);
}).then(function () {
_this.logger.log({
level: 'info',
level: "info",
message: "Prefix rules reloaded"
});
})["catch"](function (error) {
if (error) {
_this.logger.log({
level: 'error',
level: "error",
message: error
});
}
Expand All @@ -345,7 +345,7 @@ var ConnectorRIS = exports["default"] = /*#__PURE__*/function (_Connector) {
_this.subscription = input;
return (_this.params.carefulSubscription ? Promise.all([_this._subscribeToPrefixes(input), _this._subscribeToASns(input)]) : _this._subscribeToAll(input)).then(function () {
_this.logger.log({
level: 'info',
level: "info",
message: "Subscribed to monitored resources"
});
if (_this._shouldCanaryMonitoringStart()) {
Expand Down Expand Up @@ -382,7 +382,7 @@ var ConnectorRIS = exports["default"] = /*#__PURE__*/function (_Connector) {
}(_connector["default"]);
_ConnectorRIS = ConnectorRIS;
_defineProperty(ConnectorRIS, "transform", function (message) {
if (message.type === 'ris_message') {
if (message.type === "ris_message") {
try {
message = message.data;
var components = [];
Expand Down Expand Up @@ -470,7 +470,7 @@ _defineProperty(ConnectorRIS, "transform", function (message) {
} catch (error) {
throw new Error("Error during transform (".concat(_ConnectorRIS.name, "): ") + error.message);
}
} else if (message.type === 'ris_error') {
} else if (message.type === "ris_error") {
throw new Error("Error from RIS: " + message.data.message);
}
});
Expand Down
46 changes: 23 additions & 23 deletions dist/src/inputs/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,17 @@ var Input = exports["default"] = /*#__PURE__*/_createClass(function Input(env) {
}
} catch (error) {
_this.logger.log({
level: 'error',
level: "error",
message: error.message
});
}
return lessSpecifics;
});
_defineProperty(this, "getMonitoredMoreSpecifics", function () {
throw new Error('The method getMonitoredMoreSpecifics MUST be implemented');
throw new Error("The method getMonitoredMoreSpecifics MUST be implemented");
});
_defineProperty(this, "getMonitoredPrefixes", function () {
throw new Error('The method getMonitoredPrefixes MUST be implemented');
throw new Error("The method getMonitoredPrefixes MUST be implemented");
});
_defineProperty(this, "_filterIgnoreMorespecifics", function (i, prefix, includeIgnoredMorespecifics) {
return includeIgnoredMorespecifics || !i.ignoreMorespecifics || _ipSub["default"]._isEqualPrefix(i.prefix, prefix); // last piece says "or it is not a more specific"
Expand All @@ -170,28 +170,28 @@ var Input = exports["default"] = /*#__PURE__*/_createClass(function Input(env) {
});
});
_defineProperty(this, "getMonitoredASns", function () {
throw new Error('The method getMonitoredASns MUST be implemented');
throw new Error("The method getMonitoredASns MUST be implemented");
});
_defineProperty(this, "loadPrefixes", function () {
throw new Error('The method loadPrefixes MUST be implemented');
throw new Error("The method loadPrefixes MUST be implemented");
});
_defineProperty(this, "save", function (data) {
throw new Error('The method save MUST be implemented');
throw new Error("The method save MUST be implemented");
});
_defineProperty(this, "retrieve", function () {
throw new Error('The method retrieve MUST be implemented');
throw new Error("The method retrieve MUST be implemented");
});
_defineProperty(this, "generate", function () {
return _inquirer["default"].prompt([{
type: 'confirm',
name: 'continue',
type: "confirm",
name: "continue",
message: "The file prefixes.yml cannot be loaded. Do you want to auto-configure BGPalerter?",
"default": true
}]).then(function (answer) {
if (answer["continue"]) {
return _inquirer["default"].prompt([{
type: 'input',
name: 'asns',
type: "input",
name: "asns",
message: "Which Autonomous System(s) you want to monitor? (comma-separated, e.g., 2914,3333)",
"default": null,
validate: function validate(value) {
Expand All @@ -201,18 +201,18 @@ var Input = exports["default"] = /*#__PURE__*/_createClass(function Input(env) {
return asns.length > 0;
}
}, {
type: 'confirm',
name: 'm',
type: "confirm",
name: "m",
message: "Do you want to be notified when your AS is announcing a new prefix?",
"default": true
}, {
type: 'confirm',
name: 'upstreams',
type: "confirm",
name: "upstreams",
message: "Do you want to be notified when a new upstream AS appears in a BGP path?",
"default": true
}, {
type: 'confirm',
name: 'downstreams',
type: "confirm",
name: "downstreams",
message: "Do you want to be notified when a new downstream AS appears in a BGP path?",
"default": true
}]).then(function (answer) {
Expand Down Expand Up @@ -245,15 +245,15 @@ var Input = exports["default"] = /*#__PURE__*/_createClass(function Input(env) {
})["catch"](function (error) {
console.log(error);
_this.logger.log({
level: 'error',
level: "error",
message: error
});
process.exit();
});
});
_defineProperty(this, "_reGeneratePrefixList", function () {
_this.logger.log({
level: 'info',
level: "info",
message: "Updating prefix list"
});
_this.setReGeneratePrefixList();
Expand Down Expand Up @@ -312,20 +312,20 @@ var Input = exports["default"] = /*#__PURE__*/_createClass(function Input(env) {
}
if (newPrefixesNotMergeable.length) {
_this.logger.log({
level: 'info',
level: "info",
message: "The rules about ".concat(newPrefixesNotMergeable.join(", "), " cannot be automatically added to the prefix list since their origin cannot be validated. They are not RPKI valid and they are not announced by a monitored AS. Add the prefixes manually if you want to start monitoring them.")
});
}
return newPrefixList;
});
}).then(_this.save).then(function () {
_this.logger.log({
level: 'info',
level: "info",
message: "Prefix list updated."
});
})["catch"](function (error) {
_this.logger.log({
level: 'error',
level: "error",
message: error
});
});
Expand Down Expand Up @@ -354,7 +354,7 @@ var Input = exports["default"] = /*#__PURE__*/_createClass(function Input(env) {
return _this._change();
})["catch"](function (error) {
_this.logger.log({
level: 'error',
level: "error",
message: error
});
console.log(error);
Expand Down
8 changes: 4 additions & 4 deletions dist/src/inputs/inputYml.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var InputYml = exports["default"] = /*#__PURE__*/function (_Input) {
return _this._change();
})["catch"](function (error) {
_this.logger.log({
level: 'error',
level: "error",
message: error
});
});
Expand All @@ -114,7 +114,7 @@ var InputYml = exports["default"] = /*#__PURE__*/function (_Input) {
var monitoredPrefixesFile = {};
var fileContent;
if (_fs["default"].existsSync(file)) {
fileContent = _fs["default"].readFileSync(file, 'utf8');
fileContent = _fs["default"].readFileSync(file, "utf8");
try {
monitoredPrefixesFile = _jsYaml["default"].load(fileContent) || {};
_this._watchPrefixFile(file);
Expand Down Expand Up @@ -142,7 +142,7 @@ var InputYml = exports["default"] = /*#__PURE__*/function (_Input) {
uniqueAsns[asn] = true;
var item = Object.assign({
asn: new _model.AS(asn),
group: ['default']
group: ["default"]
}, monitoredPrefixesFile.options.monitorASns[asn]);
if (item.upstreams && item.upstreams.length) {
item.upstreams = new _model.AS(item.upstreams);
Expand All @@ -166,7 +166,7 @@ var InputYml = exports["default"] = /*#__PURE__*/function (_Input) {
monitoredPrefixesFile[i].asn = new _model.AS(monitoredPrefixesFile[i].asn);
return Object.assign({
prefix: i,
group: ['default'],
group: ["default"],
ignore: false,
excludeMonitors: [],
includeMonitors: []
Expand Down
Loading

0 comments on commit d77711a

Please sign in to comment.