systeminformation 5.10.7 → 5.11.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 +3 -1
- package/lib/network.js +40 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -101,6 +101,7 @@ si.cpu()
|
|
|
101
101
|
|
|
102
102
|
(last 7 major and minor version releases)
|
|
103
103
|
|
|
104
|
+
- Version 5.11.0: `networkInterfaces()` added default property and default parameter
|
|
104
105
|
- Version 5.10.0: basic `android` support
|
|
105
106
|
- Version 5.9.0: `graphics()` added properties (macOS)
|
|
106
107
|
- Version 5.8.0: `disksIO()` added waitTime, waitPercent (linux)
|
|
@@ -539,9 +540,10 @@ Full function reference with examples can be found at [https://systeminformation
|
|
|
539
540
|
|
|
540
541
|
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
|
|
541
542
|
| --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- |
|
|
542
|
-
| si.networkInterfaces(cb) | [{...}] | X | X | X | X | X | array of network interfaces |
|
|
543
|
+
| si.networkInterfaces(cb) | [{...}] | X | X | X | X | X | array of network interfaces<br>With the 'default' parameter it returns<br>only the default interface |
|
|
543
544
|
| | [0].iface | X | X | X | X | X | interface |
|
|
544
545
|
| | [0].ifaceName | X | X | X | X | X | interface name (differs on Windows) |
|
|
546
|
+
| | [0].default | X | X | X | X | X | true if this is the default interface |
|
|
545
547
|
| | [0].ip4 | X | X | X | X | X | ip4 address |
|
|
546
548
|
| | [0].ip4subnet | X | X | X | X | X | ip4 subnet mask |
|
|
547
549
|
| | [0].ip6 | X | X | X | X | X | ip6 address |
|
package/lib/network.js
CHANGED
|
@@ -692,17 +692,29 @@ function testVirtualNic(iface, ifaceName, mac) {
|
|
|
692
692
|
} else { return false; }
|
|
693
693
|
}
|
|
694
694
|
|
|
695
|
-
function networkInterfaces(callback, rescan) {
|
|
695
|
+
function networkInterfaces(callback, rescan, defaultString) {
|
|
696
|
+
|
|
697
|
+
if (typeof callback === 'string') {
|
|
698
|
+
defaultString = callback;
|
|
699
|
+
rescan = true;
|
|
700
|
+
callback = null;
|
|
701
|
+
}
|
|
696
702
|
|
|
697
703
|
if (typeof callback === 'boolean') {
|
|
698
704
|
rescan = callback;
|
|
699
705
|
callback = null;
|
|
706
|
+
defaultString = '';
|
|
700
707
|
}
|
|
701
708
|
if (typeof rescan === 'undefined') {
|
|
702
709
|
rescan = true;
|
|
703
710
|
}
|
|
711
|
+
defaultString = defaultString || '';
|
|
712
|
+
defaultString = '' + defaultString;
|
|
713
|
+
|
|
704
714
|
return new Promise((resolve) => {
|
|
705
715
|
process.nextTick(() => {
|
|
716
|
+
const defaultInterface = getDefaultNetworkInterface();
|
|
717
|
+
|
|
706
718
|
let ifaces = os.networkInterfaces();
|
|
707
719
|
|
|
708
720
|
let result = [];
|
|
@@ -730,6 +742,7 @@ function networkInterfaces(callback, rescan) {
|
|
|
730
742
|
result.push({
|
|
731
743
|
iface: nic.iface,
|
|
732
744
|
ifaceName: nic.iface,
|
|
745
|
+
default: nic.iface === defaultInterface,
|
|
733
746
|
ip4: nic.ip4,
|
|
734
747
|
ip4subnet: nic.ip4subnet || '',
|
|
735
748
|
ip6: nic.ip6,
|
|
@@ -750,6 +763,14 @@ function networkInterfaces(callback, rescan) {
|
|
|
750
763
|
});
|
|
751
764
|
});
|
|
752
765
|
_networkInterfaces = result;
|
|
766
|
+
if (defaultString.toLowerCase().indexOf('default') >= 0) {
|
|
767
|
+
result = result.filter(item => item.default);
|
|
768
|
+
if (result.length > 0) {
|
|
769
|
+
result = result[0];
|
|
770
|
+
} else {
|
|
771
|
+
result = [];
|
|
772
|
+
}
|
|
773
|
+
}
|
|
753
774
|
if (callback) { callback(result); }
|
|
754
775
|
resolve(result);
|
|
755
776
|
}
|
|
@@ -863,6 +884,7 @@ function networkInterfaces(callback, rescan) {
|
|
|
863
884
|
result.push({
|
|
864
885
|
iface,
|
|
865
886
|
ifaceName,
|
|
887
|
+
default: iface === defaultInterface,
|
|
866
888
|
ip4,
|
|
867
889
|
ip4subnet,
|
|
868
890
|
ip6,
|
|
@@ -884,6 +906,14 @@ function networkInterfaces(callback, rescan) {
|
|
|
884
906
|
}
|
|
885
907
|
}
|
|
886
908
|
_networkInterfaces = result;
|
|
909
|
+
if (defaultString.toLowerCase().indexOf('default') >= 0) {
|
|
910
|
+
result = result.filter(item => item.default);
|
|
911
|
+
if (result.length > 0) {
|
|
912
|
+
result = result[0];
|
|
913
|
+
} else {
|
|
914
|
+
result = [];
|
|
915
|
+
}
|
|
916
|
+
}
|
|
887
917
|
if (callback) { callback(result); }
|
|
888
918
|
resolve(result);
|
|
889
919
|
}
|
|
@@ -990,6 +1020,7 @@ function networkInterfaces(callback, rescan) {
|
|
|
990
1020
|
result.push({
|
|
991
1021
|
iface,
|
|
992
1022
|
ifaceName,
|
|
1023
|
+
default: iface === defaultInterface,
|
|
993
1024
|
ip4,
|
|
994
1025
|
ip4subnet,
|
|
995
1026
|
ip6,
|
|
@@ -1011,6 +1042,14 @@ function networkInterfaces(callback, rescan) {
|
|
|
1011
1042
|
}
|
|
1012
1043
|
}
|
|
1013
1044
|
_networkInterfaces = result;
|
|
1045
|
+
if (defaultString.toLowerCase().indexOf('default') >= 0) {
|
|
1046
|
+
result = result.filter(item => item.default);
|
|
1047
|
+
if (result.length > 0) {
|
|
1048
|
+
result = result[0];
|
|
1049
|
+
} else {
|
|
1050
|
+
result = [];
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1014
1053
|
if (callback) { callback(result); }
|
|
1015
1054
|
resolve(result);
|
|
1016
1055
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "systeminformation",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.0",
|
|
4
4
|
"description": "Advanced, lightweight system and OS information library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",
|