net-snmp 3.8.3 → 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 +16 -0
- package/example/snmp-receiver.js +2 -1
- package/index.js +32 -7
- 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
|
@@ -3227,6 +3235,14 @@ Example programs are included under the module's `example` directory.
|
|
3227
3235
|
|
3228
3236
|
* Fix incorrect user level assignment
|
3229
3237
|
|
3238
|
+
## Version 3.8.4 - 29/09/2022
|
3239
|
+
|
3240
|
+
* Fix IpAddress byte array set request handling
|
3241
|
+
|
3242
|
+
## Version 3.9.0 - 11/12/2022
|
3243
|
+
|
3244
|
+
* Add ProcessingError to handle agent/receiver decode failures
|
3245
|
+
|
3230
3246
|
# License
|
3231
3247
|
|
3232
3248
|
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
|
}
|
@@ -4603,7 +4627,8 @@ Agent.prototype.castSetValue = function ( type, value ) {
|
|
4603
4627
|
|
4604
4628
|
case ObjectType.IpAddress:
|
4605
4629
|
// A 32-bit internet address represented as OCTET STRING of length 4
|
4606
|
-
|
4630
|
+
var bytes = value.split(".");
|
4631
|
+
if ( typeof value != "string" || bytes.length != 4 ) {
|
4607
4632
|
throw new Error("Invalid IpAddress", value);
|
4608
4633
|
}
|
4609
4634
|
return value;
|