net-snmp 3.6.1 → 3.6.2
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 +7 -0
- package/example/snmp-receiver.js +2 -1
- package/index.js +20 -10
- package/package.json +1 -1
- package/test/receiver-test.sh +2 -3
package/README.md
CHANGED
@@ -1452,6 +1452,7 @@ class:
|
|
1452
1452
|
var options = {
|
1453
1453
|
port: 162,
|
1454
1454
|
disableAuthorization: false,
|
1455
|
+
includeAuthentication: false,
|
1455
1456
|
accessControlModelType: snmp.AccessControlModelType.None,
|
1456
1457
|
engineID: "8000B98380XXXXXXXXXXXXXXXXXXXXXXXX", // where the X's are random hex digits
|
1457
1458
|
address: null,
|
@@ -1483,6 +1484,8 @@ an object, possibly empty, and can contain the following fields:
|
|
1483
1484
|
* `transport` - the transport family to use - defaults to `udp4`
|
1484
1485
|
* `address` - the IP address to bind to - default to `null`, which means bind to all IP
|
1485
1486
|
addresses
|
1487
|
+
* `includeAuthentication` - adds the community (v1/2c) or user name (v3) information
|
1488
|
+
to the notification callback - defaults to `false`
|
1486
1489
|
|
1487
1490
|
The `callback` parameter is a callback function of the form
|
1488
1491
|
`function (error, notification)`. On an error condition, the `notification`
|
@@ -3174,6 +3177,10 @@ Example programs are included under the module's `example` directory.
|
|
3174
3177
|
|
3175
3178
|
* Add v3 context to non-initial PDUs
|
3176
3179
|
|
3180
|
+
## Version 3.6.2 - 07/04/2022
|
3181
|
+
|
3182
|
+
* Add option for receiver to receive client authentication identity
|
3183
|
+
|
3177
3184
|
# License
|
3178
3185
|
|
3179
3186
|
Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
|
package/example/snmp-receiver.js
CHANGED
package/index.js
CHANGED
@@ -3126,6 +3126,7 @@ var Receiver = function (options, callback) {
|
|
3126
3126
|
this.port = options.port || 162;
|
3127
3127
|
options.port = this.port;
|
3128
3128
|
this.disableAuthorization = options.disableAuthorization || false;
|
3129
|
+
this.includeAuthentication = options.includeAuthentication || false;
|
3129
3130
|
this.context = (options && options.context) ? options.context : "";
|
3130
3131
|
this.listener = new Listener (options, this);
|
3131
3132
|
};
|
@@ -3162,29 +3163,38 @@ Receiver.prototype.onMsg = function (buffer, rinfo) {
|
|
3162
3163
|
// Inform/trap processing
|
3163
3164
|
// debug (JSON.stringify (message.pdu, null, 2));
|
3164
3165
|
if ( message.pdu.type == PduType.Trap || message.pdu.type == PduType.TrapV2 ) {
|
3165
|
-
this.callback (null, this.formatCallbackData (message
|
3166
|
+
this.callback (null, this.formatCallbackData (message, rinfo) );
|
3166
3167
|
} else if ( message.pdu.type == PduType.InformRequest ) {
|
3167
3168
|
message.pdu.type = PduType.GetResponse;
|
3168
3169
|
message.buffer = null;
|
3169
3170
|
message.setReportable (false);
|
3170
3171
|
this.listener.send (message, rinfo);
|
3171
3172
|
message.pdu.type = PduType.InformRequest;
|
3172
|
-
this.callback (null, this.formatCallbackData (message
|
3173
|
+
this.callback (null, this.formatCallbackData (message, rinfo) );
|
3173
3174
|
} else {
|
3174
3175
|
this.callback (new RequestInvalidError ("Unexpected PDU type " + message.pdu.type + " (" + PduType[message.pdu.type] + ")"));
|
3175
3176
|
}
|
3176
3177
|
};
|
3177
3178
|
|
3178
|
-
Receiver.prototype.formatCallbackData = function (
|
3179
|
-
if ( pdu.contextEngineID ) {
|
3180
|
-
pdu.contextEngineID = pdu.contextEngineID.toString('hex');
|
3179
|
+
Receiver.prototype.formatCallbackData = function (message, rinfo) {
|
3180
|
+
if ( message.pdu.contextEngineID ) {
|
3181
|
+
message.pdu.contextEngineID = message.pdu.contextEngineID.toString('hex');
|
3181
3182
|
}
|
3182
|
-
delete pdu.nonRepeaters;
|
3183
|
-
delete pdu.maxRepetitions;
|
3184
|
-
|
3185
|
-
pdu: pdu,
|
3186
|
-
rinfo: rinfo
|
3183
|
+
delete message.pdu.nonRepeaters;
|
3184
|
+
delete message.pdu.maxRepetitions;
|
3185
|
+
const formattedData = {
|
3186
|
+
pdu: message.pdu,
|
3187
|
+
rinfo: rinfo
|
3187
3188
|
};
|
3189
|
+
if (this.includeAuthentication) {
|
3190
|
+
if (message.community) {
|
3191
|
+
formattedData.pdu.community = message.community;
|
3192
|
+
} else if (message.user) {
|
3193
|
+
formattedData.pdu.user = message.user.name;
|
3194
|
+
}
|
3195
|
+
}
|
3196
|
+
|
3197
|
+
return formattedData;
|
3188
3198
|
};
|
3189
3199
|
|
3190
3200
|
Receiver.prototype.close = function() {
|
package/package.json
CHANGED
package/test/receiver-test.sh
CHANGED
@@ -61,8 +61,8 @@ node ${HOME_DIR}/example/snmp-trap.js -v 3 -l authNoPriv -u ${USER_AUTH} -a ${AU
|
|
61
61
|
node ${HOME_DIR}/example/snmp-trap.js -v 3 -l authPriv -u ${USER_PRIV} -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} -x ${PRIV_PROTOCOL} -X ${PRIV_KEY} ${PARAMS} ${HOST} ${TRAP_OID}
|
62
62
|
node ${HOME_DIR}/example/snmp-inform.js -v 2c -c ${COMMUNITY} ${PARAMS} ${HOST} ${TRAP_OID}
|
63
63
|
node ${HOME_DIR}/example/snmp-inform.js -v 3 -l noAuthNoPriv -u ${USER_NONE} ${PARAMS} ${HOST} ${TRAP_OID}
|
64
|
-
node ${HOME_DIR}/example/snmp-inform.js -v 3 -u ${USER_AUTH} -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} ${PARAMS} ${HOST} ${TRAP_OID}
|
65
|
-
node ${HOME_DIR}/example/snmp-inform.js -v 3 -u ${USER_PRIV} -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} -x ${PRIV_PROTOCOL} -X ${PRIV_KEY} ${PARAMS} ${HOST} ${TRAP_OID}
|
64
|
+
node ${HOME_DIR}/example/snmp-inform.js -v 3 -l authNoPriv -u ${USER_AUTH} -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} ${PARAMS} ${HOST} ${TRAP_OID}
|
65
|
+
node ${HOME_DIR}/example/snmp-inform.js -v 3 -l authPriv -u ${USER_PRIV} -a ${AUTH_PROTOCOL} -A ${AUTH_KEY} -x ${PRIV_PROTOCOL} -X ${PRIV_KEY} ${PARAMS} ${HOST} ${TRAP_OID}
|
66
66
|
ENDOFCMDS
|
67
67
|
|
68
68
|
COUNT=1
|
@@ -81,4 +81,3 @@ while read CMD ; do
|
|
81
81
|
done <${CMDS}
|
82
82
|
|
83
83
|
rm -f ${CMDS}
|
84
|
-
|