net-snmp 3.5.8 → 3.6.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 +4 -0
- package/index.js +70 -54
- package/package.json +1 -1
package/README.md
CHANGED
@@ -3166,6 +3166,10 @@ Example programs are included under the module's `example` directory.
|
|
3166
3166
|
|
3167
3167
|
* Fix processing of negative integers larger than 32 bits
|
3168
3168
|
|
3169
|
+
## Version 3.6.0 - 18/02/2022
|
3170
|
+
|
3171
|
+
* Add calculated key cache to remove authNoPriv and authPriv performance bottleneck
|
3172
|
+
|
3169
3173
|
# License
|
3170
3174
|
|
3171
3175
|
Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
|
package/index.js
CHANGED
@@ -427,16 +427,16 @@ function readUint (buffer, isSigned) {
|
|
427
427
|
value *= 256;
|
428
428
|
value += buffer.readByte ();
|
429
429
|
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
430
|
+
if (isSigned && i <= 0) {
|
431
|
+
if ((value & 0x80) == 0x80) {
|
432
|
+
signedBitSet = true;
|
433
|
+
}
|
434
|
+
}
|
435
435
|
}
|
436
436
|
|
437
|
-
|
438
|
-
|
439
|
-
|
437
|
+
if (signedBitSet) {
|
438
|
+
value -= 2 ** (i * 8);
|
439
|
+
}
|
440
440
|
|
441
441
|
return value;
|
442
442
|
}
|
@@ -934,17 +934,32 @@ Authentication.algorithms[AuthProtocols.sha] = {
|
|
934
934
|
CRYPTO_ALGORITHM: 'sha1'
|
935
935
|
};
|
936
936
|
|
937
|
+
Authentication.authToKeyCache = {};
|
938
|
+
|
939
|
+
Authentication.computeCacheKey = function (authProtocol, authPasswordString, engineID) {
|
940
|
+
var engineIDString = engineID.toString('base64');
|
941
|
+
return authProtocol + authPasswordString + engineIDString;
|
942
|
+
};
|
943
|
+
|
937
944
|
// Adapted from RFC3414 Appendix A.2.1. Password to Key Sample Code for MD5
|
938
945
|
Authentication.passwordToKey = function (authProtocol, authPasswordString, engineID) {
|
939
946
|
var hashAlgorithm;
|
940
947
|
var firstDigest;
|
941
948
|
var finalDigest;
|
942
|
-
var buf
|
949
|
+
var buf;
|
943
950
|
var bufOffset = 0;
|
944
951
|
var passwordIndex = 0;
|
945
952
|
var count = 0;
|
946
|
-
var password
|
953
|
+
var password;
|
947
954
|
var cryptoAlgorithm = Authentication.algorithms[authProtocol].CRYPTO_ALGORITHM;
|
955
|
+
|
956
|
+
var cacheKey = Authentication.computeCacheKey(authProtocol, authPasswordString, engineID);
|
957
|
+
if (Authentication.authToKeyCache[cacheKey] !== undefined) {
|
958
|
+
return Authentication.authToKeyCache[cacheKey];
|
959
|
+
}
|
960
|
+
|
961
|
+
buf = Buffer.alloc (Authentication.HMAC_BUFFER_SIZE);
|
962
|
+
password = Buffer.from (authPasswordString);
|
948
963
|
|
949
964
|
while (count < Authentication.HMAC_BUFFER_SIZE) {
|
950
965
|
for (var i = 0; i < Authentication.HMAC_BLOCK_SIZE; i++) {
|
@@ -964,6 +979,7 @@ Authentication.passwordToKey = function (authProtocol, authPasswordString, engin
|
|
964
979
|
finalDigest = hashAlgorithm.digest();
|
965
980
|
// debug ("Localized key: " + finalDigest.toString('hex'));
|
966
981
|
|
982
|
+
Authentication.authToKeyCache[cacheKey] = finalDigest;
|
967
983
|
return finalDigest;
|
968
984
|
};
|
969
985
|
|
@@ -3546,11 +3562,11 @@ MibNode.prototype.getConstraintsFromProvider = function () {
|
|
3546
3562
|
};
|
3547
3563
|
|
3548
3564
|
MibNode.prototype.setValue = function (newValue) {
|
3549
|
-
|
3550
|
-
|
3551
|
-
|
3552
|
-
|
3553
|
-
|
3565
|
+
var len;
|
3566
|
+
var min;
|
3567
|
+
var max;
|
3568
|
+
var range;
|
3569
|
+
var found = false;
|
3554
3570
|
var constraints = this.getConstraintsFromProvider ();
|
3555
3571
|
if ( ! constraints ) {
|
3556
3572
|
this.value = newValue;
|
@@ -3561,35 +3577,35 @@ MibNode.prototype.setValue = function (newValue) {
|
|
3561
3577
|
return false;
|
3562
3578
|
}
|
3563
3579
|
} else if ( constraints.ranges ) {
|
3564
|
-
|
3565
|
-
|
3566
|
-
|
3567
|
-
|
3568
|
-
|
3569
|
-
|
3570
|
-
|
3571
|
-
|
3572
|
-
|
3573
|
-
|
3574
|
-
|
3575
|
-
|
3576
|
-
|
3577
|
-
|
3578
|
-
|
3579
|
-
|
3580
|
-
|
3581
|
-
|
3582
|
-
|
3583
|
-
|
3584
|
-
|
3585
|
-
|
3586
|
-
|
3587
|
-
|
3588
|
-
|
3589
|
-
|
3590
|
-
|
3591
|
-
|
3592
|
-
|
3580
|
+
for ( range of constraints.ranges ) {
|
3581
|
+
min = "min" in range ? range.min : Number.MIN_SAFE_INTEGER;
|
3582
|
+
max = "max" in range ? range.max : Number.MAX_SAFE_INTEGER;
|
3583
|
+
if ( newValue >= min && newValue <= max ) {
|
3584
|
+
found = true;
|
3585
|
+
break;
|
3586
|
+
}
|
3587
|
+
}
|
3588
|
+
if ( ! found ) {
|
3589
|
+
return false;
|
3590
|
+
}
|
3591
|
+
} else if ( constraints.sizes ) {
|
3592
|
+
// if size is constrained, value must have a length property
|
3593
|
+
if ( ! ( "length" in newValue ) ) {
|
3594
|
+
return false;
|
3595
|
+
}
|
3596
|
+
len = newValue.length;
|
3597
|
+
for ( range of constraints.sizes ) {
|
3598
|
+
min = "min" in range ? range.min : Number.MIN_SAFE_INTEGER;
|
3599
|
+
max = "max" in range ? range.max : Number.MAX_SAFE_INTEGER;
|
3600
|
+
if ( len >= min && len <= max ) {
|
3601
|
+
found = true;
|
3602
|
+
break;
|
3603
|
+
}
|
3604
|
+
}
|
3605
|
+
if ( ! found ) {
|
3606
|
+
return false;
|
3607
|
+
}
|
3608
|
+
}
|
3593
3609
|
this.value = newValue;
|
3594
3610
|
return true;
|
3595
3611
|
};
|
@@ -3977,25 +3993,25 @@ Mib.prototype.setTableRowDefaultValues = function (name, values) {
|
|
3977
3993
|
};
|
3978
3994
|
|
3979
3995
|
Mib.prototype.setScalarRanges = function (name, ranges ) {
|
3980
|
-
|
3981
|
-
|
3996
|
+
let provider = this.getProvider(name);
|
3997
|
+
provider.constraints = { ranges };
|
3982
3998
|
};
|
3983
3999
|
|
3984
4000
|
Mib.prototype.setTableColumnRanges = function(name, column, ranges ) {
|
3985
|
-
|
3986
|
-
|
3987
|
-
|
4001
|
+
let provider = this.getProvider(name);
|
4002
|
+
let tc = provider.tableColumns;
|
4003
|
+
tc[column].constraints = { ranges };
|
3988
4004
|
};
|
3989
4005
|
|
3990
4006
|
Mib.prototype.setScalarSizes = function (name, sizes ) {
|
3991
|
-
|
3992
|
-
|
4007
|
+
let provider = this.getProvider(name);
|
4008
|
+
provider.constraints = { sizes };
|
3993
4009
|
};
|
3994
4010
|
|
3995
4011
|
Mib.prototype.setTableColumnSizes = function(name, column, sizes ) {
|
3996
|
-
|
3997
|
-
|
3998
|
-
|
4012
|
+
let provider = this.getProvider(name);
|
4013
|
+
let tc = provider.tableColumns;
|
4014
|
+
tc[column].constraints = { sizes };
|
3999
4015
|
};
|
4000
4016
|
|
4001
4017
|
Mib.prototype.registerProviders = function (providers) {
|