net-snmp 3.8.4 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -517,6 +517,14 @@ supplemental information. An authentication error, for example -- code
517
517
  `ResponseInvalidCode.EAuthFailure` -- will contain a map in `info`
518
518
  with the attempted authentication data which failed to authenticate.
519
519
 
520
+ ## snmp.ProcessingError
521
+
522
+ If a receiver or an agent receives a packet it is unable to decode,
523
+ then it will produce a `ProcessingError` containing:
524
+ * `rinfo` information on the origin of the packet,
525
+ * a `buffer` containing the packet contents, and
526
+ * an `error` containing the original error encountered during processing.
527
+
520
528
  # Using This Module: Command & Notification Generator
521
529
 
522
530
  This library provides a `Session` class to provide support for building
@@ -3231,6 +3239,10 @@ Example programs are included under the module's `example` directory.
3231
3239
 
3232
3240
  * Fix IpAddress byte array set request handling
3233
3241
 
3242
+ ## Version 3.9.0 - 11/12/2022
3243
+
3244
+ * Add ProcessingError to handle agent/receiver decode failures
3245
+
3234
3246
  # License
3235
3247
 
3236
3248
  Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
@@ -15,7 +15,8 @@ var cb = function(error, trap) {
15
15
  var now = new Date().toLocaleString();
16
16
  var trapType;
17
17
  if (error) {
18
- console.log(now + ": " + error.message);
18
+ console.log (now + ": " + error.message);
19
+ console.error (error);
19
20
  } else {
20
21
  trapType = snmp.PduType[trap.pdu.type] || "Unknown";
21
22
  if ( verbose ) {
package/index.js CHANGED
@@ -315,6 +315,16 @@ function RequestTimedOutError (message) {
315
315
  }
316
316
  util.inherits (RequestTimedOutError, Error);
317
317
 
318
+ function ProcessingError (message, error, rinfo, buffer) {
319
+ this.name = "ProcessingError";
320
+ this.message = message;
321
+ this.error = error;
322
+ this.rinfo = rinfo;
323
+ this.buffer = buffer;
324
+ Error.captureStackTrace(this, ProcessingError);
325
+ }
326
+ util.inherits (ProcessingError, Error);
327
+
318
328
  /*****************************************************************************
319
329
  ** OID and varbind helper functions
320
330
  **/
@@ -3071,8 +3081,15 @@ Receiver.prototype.getAuthorizer = function () {
3071
3081
  };
3072
3082
 
3073
3083
  Receiver.prototype.onMsg = function (buffer, rinfo) {
3074
- var message = Listener.processIncoming (buffer, this.authorizer, this.callback);
3075
- var reportMessage;
3084
+
3085
+ let message;
3086
+
3087
+ try {
3088
+ message = Listener.processIncoming (buffer, this.authorizer, this.callback);
3089
+ } catch (error) {
3090
+ this.callback (new ProcessingError ("Failure to process incoming message", error, rinfo, buffer));
3091
+ return;
3092
+ }
3076
3093
 
3077
3094
  if ( ! message ) {
3078
3095
  return;
@@ -3090,7 +3107,7 @@ Receiver.prototype.onMsg = function (buffer, rinfo) {
3090
3107
  this.callback (new RequestInvalidError ("Only discovery GetRequests are supported and this message does not have the reportable flag set"));
3091
3108
  return;
3092
3109
  }
3093
- reportMessage = message.createReportResponseMessage (this.engine, this.context);
3110
+ let reportMessage = message.createReportResponseMessage (this.engine, this.context);
3094
3111
  this.listener.send (reportMessage, rinfo);
3095
3112
  return;
3096
3113
  }
@@ -4536,8 +4553,15 @@ Agent.prototype.tableRowStatusHandlerInternal = function (createRequest) {
4536
4553
  };
4537
4554
 
4538
4555
  Agent.prototype.onMsg = function (buffer, rinfo) {
4539
- var message = Listener.processIncoming (buffer, this.authorizer, this.callback);
4540
- var reportMessage;
4556
+
4557
+ let message;
4558
+
4559
+ try {
4560
+ message = Listener.processIncoming (buffer, this.authorizer, this.callback);
4561
+ } catch (error) {
4562
+ this.callback (new ProcessingError ("Failure to process incoming message", error, rinfo, buffer));
4563
+ return;
4564
+ }
4541
4565
 
4542
4566
  if ( ! message ) {
4543
4567
  return;
@@ -4546,7 +4570,7 @@ Agent.prototype.onMsg = function (buffer, rinfo) {
4546
4570
  // SNMPv3 discovery
4547
4571
  if ( message.version == Version3 && message.pdu.type == PduType.GetRequest &&
4548
4572
  ! message.hasAuthoritativeEngineID() && message.isReportable () ) {
4549
- reportMessage = message.createReportResponseMessage (this.engine, this.context);
4573
+ let reportMessage = message.createReportResponseMessage (this.engine, this.context);
4550
4574
  this.listener.send (reportMessage, rinfo);
4551
4575
  return;
4552
4576
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "net-snmp",
3
- "version": "3.8.4",
3
+ "version": "3.9.0",
4
4
  "description": "JavaScript implementation of the Simple Network Management Protocol (SNMP)",
5
5
  "main": "index.js",
6
6
  "directories": {