net-snmp 3.8.4 → 3.9.1
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 +16 -0
- package/example/snmp-receiver.js +2 -1
- package/index.js +30 -6
- package/lib/mib.js +3 -3
- package/package.json +1 -1
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,14 @@ 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
|
+
|
3246
|
+
## Version 3.9.1 - 16/03/2023
|
3247
|
+
|
3248
|
+
* Fix MIB parsing of unclosed brackets in comments
|
3249
|
+
|
3234
3250
|
# License
|
3235
3251
|
|
3236
3252
|
Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
|
package/example/snmp-receiver.js
CHANGED
@@ -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
|
-
|
3075
|
-
|
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
|
-
|
4540
|
-
|
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/lib/mib.js
CHANGED
@@ -159,10 +159,10 @@ var MIB = function (dir) {
|
|
159
159
|
}
|
160
160
|
break;
|
161
161
|
case '{':
|
162
|
-
if (this.CharBuffer.isEqual) { this.CharBuffer.isOID = true; }
|
162
|
+
if ( ! this.CharBuffer.isComment && this.CharBuffer.isEqual ) { this.CharBuffer.isOID = true; }
|
163
163
|
case '[':
|
164
164
|
case '(':
|
165
|
-
if ( ! this.CharBuffer.isString ) {
|
165
|
+
if ( ! this.CharBuffer.isComment && ! this.CharBuffer.isString ) {
|
166
166
|
this.CharBuffer.nested++;
|
167
167
|
if ( char == '(') {
|
168
168
|
this.CharBuffer.inGroup++;
|
@@ -182,7 +182,7 @@ var MIB = function (dir) {
|
|
182
182
|
case '}':
|
183
183
|
case ']':
|
184
184
|
case ')':
|
185
|
-
if ( ! this.CharBuffer.isString ) {
|
185
|
+
if ( ! this.CharBuffer.isComment && ! this.CharBuffer.isString ) {
|
186
186
|
this.CharBuffer.nested--;
|
187
187
|
if (this.CharBuffer.nested < 0) {
|
188
188
|
this.CharBuffer.nested = 0;
|