systeminformation 5.11.12 → 5.11.15

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/lib/battery.js CHANGED
@@ -185,7 +185,7 @@ module.exports = function (callback) {
185
185
  result.voltage = parseInt('0' + util.getValue(lines, 'voltage', '='), 10) / 1000.0;
186
186
  result.capacityUnit = result.voltage ? 'mWh' : 'mAh';
187
187
  result.maxCapacity = Math.round(parseInt('0' + util.getValue(lines, 'applerawmaxcapacity', '='), 10) * (result.voltage || 1));
188
- result.currentCapacity = Math.round(parseInt('0' + util.getValue(lines, 'applerawxcurrentcapacity', '='), 10) * (result.voltage || 1));
188
+ result.currentCapacity = Math.round(parseInt('0' + util.getValue(lines, 'applerawcurrentcapacity', '='), 10) * (result.voltage || 1));
189
189
  result.designedCapacity = Math.round(parseInt('0' + util.getValue(lines, 'DesignCapacity', '='), 10) * (result.voltage || 1));
190
190
  result.manufacturer = 'Apple';
191
191
  result.serial = util.getValue(lines, 'BatterySerialNumber', '=');
package/lib/index.d.ts CHANGED
@@ -876,9 +876,10 @@ export namespace Systeminformation {
876
876
  default: boolean;
877
877
  revision: string;
878
878
  driver: string;
879
+ channel: string;
879
880
  in: boolean;
880
881
  out: boolean;
881
- interfaceType: string;
882
+ type: string;
882
883
  status: string;
883
884
  }
884
885
 
package/lib/network.js CHANGED
@@ -108,6 +108,7 @@ function getDefaultNetworkInterface() {
108
108
  if (_linux) { cmd = 'ip route 2> /dev/null | grep default | awk \'{print $5}\''; }
109
109
  if (_darwin) { cmd = 'route -n get default 2>/dev/null | grep interface: | awk \'{print $2}\''; }
110
110
  if (_freebsd || _openbsd || _netbsd || _sunos) { cmd = 'route get 0.0.0.0 | grep interface:'; }
111
+ // console.log('SYNC - default darwin 3');
111
112
  let result = execSync(cmd);
112
113
  ifacename = result.toString().split('\n')[0];
113
114
  if (ifacename.indexOf(':') > -1) {
@@ -172,6 +173,7 @@ function getMacAddresses() {
172
173
  if (_darwin) {
173
174
  try {
174
175
  const cmd = '/sbin/ifconfig';
176
+ // console.log('SYNC - macAde darwin 6');
175
177
  let res = execSync(cmd);
176
178
  const lines = res.toString().split('\n');
177
179
  for (let i = 0; i < lines.length; i++) {
@@ -504,6 +506,7 @@ function parseLinesDarwinNics(sections) {
504
506
  function getDarwinNics() {
505
507
  const cmd = '/sbin/ifconfig -v';
506
508
  try {
509
+ // console.log('SYNC - Nics darwin 12');
507
510
  const lines = execSync(cmd, { maxBuffer: 1024 * 20000 }).toString().split('\n');
508
511
  const nsections = splitSectionsNics(lines);
509
512
  return (parseLinesDarwinNics(nsections));
@@ -622,6 +625,7 @@ function getDarwinIfaceDHCPstatus(iface) {
622
625
  let result = false;
623
626
  const cmd = `ipconfig getpacket "${iface}" 2>/dev/null | grep lease_time;`;
624
627
  try {
628
+ // console.log('SYNC - DHCP status darwin 17');
625
629
  const lines = execSync(cmd).toString().split('\n');
626
630
  if (lines.length && lines[0].startsWith('lease_time')) {
627
631
  result = true;
@@ -713,7 +717,6 @@ function networkInterfaces(callback, rescan, defaultString) {
713
717
 
714
718
  return new Promise((resolve) => {
715
719
  process.nextTick(() => {
716
- const defaultInterface = getDefaultNetworkInterface();
717
720
 
718
721
  let ifaces = os.networkInterfaces();
719
722
 
@@ -723,56 +726,67 @@ function networkInterfaces(callback, rescan, defaultString) {
723
726
  let nics8021xInfo = [];
724
727
  // seperate handling in OSX
725
728
  if (_darwin || _freebsd || _openbsd || _netbsd) {
726
- nics = getDarwinNics();
729
+ if ((JSON.stringify(ifaces) === JSON.stringify(_ifaces)) && !rescan) {
730
+ // no changes - just return object
731
+ result = _networkInterfaces;
727
732
 
733
+ if (callback) { callback(result); }
734
+ resolve(result);
735
+ } else {
736
+ const defaultInterface = getDefaultNetworkInterface();
737
+ _ifaces = JSON.parse(JSON.stringify(ifaces));
728
738
 
729
- nics.forEach(nic => {
739
+ nics = getDarwinNics();
730
740
 
731
- if ({}.hasOwnProperty.call(ifaces, nic.iface)) {
732
- ifaces[nic.iface].forEach(function (details) {
733
- if (details.family === 'IPv4') {
734
- nic.ip4subnet = details.netmask;
735
- }
736
- if (details.family === 'IPv6') {
737
- nic.ip6subnet = details.netmask;
738
- }
739
- });
740
- }
741
741
 
742
- result.push({
743
- iface: nic.iface,
744
- ifaceName: nic.iface,
745
- default: nic.iface === defaultInterface,
746
- ip4: nic.ip4,
747
- ip4subnet: nic.ip4subnet || '',
748
- ip6: nic.ip6,
749
- ip6subnet: nic.ip6subnet || '',
750
- mac: nic.mac,
751
- internal: nic.internal,
752
- virtual: nic.internal ? false : testVirtualNic(nic.iface, nic.iface, nic.mac),
753
- operstate: nic.operstate,
754
- type: nic.type,
755
- duplex: nic.duplex,
756
- mtu: nic.mtu,
757
- speed: nic.speed,
758
- dhcp: getDarwinIfaceDHCPstatus(nic.iface),
759
- dnsSuffix: '',
760
- ieee8021xAuth: '',
761
- ieee8021xState: '',
762
- carrierChanges: 0
742
+ nics.forEach(nic => {
743
+
744
+ if ({}.hasOwnProperty.call(ifaces, nic.iface)) {
745
+ ifaces[nic.iface].forEach(function (details) {
746
+ if (details.family === 'IPv4' || details.family === 4) {
747
+ nic.ip4subnet = details.netmask;
748
+ }
749
+ if (details.family === 'IPv6' || details.family === 6) {
750
+ nic.ip6subnet = details.netmask;
751
+ }
752
+ });
753
+ }
754
+
755
+ result.push({
756
+ iface: nic.iface,
757
+ ifaceName: nic.iface,
758
+ default: nic.iface === defaultInterface,
759
+ ip4: nic.ip4,
760
+ ip4subnet: nic.ip4subnet || '',
761
+ ip6: nic.ip6,
762
+ ip6subnet: nic.ip6subnet || '',
763
+ mac: nic.mac,
764
+ internal: nic.internal,
765
+ virtual: nic.internal ? false : testVirtualNic(nic.iface, nic.iface, nic.mac),
766
+ operstate: nic.operstate,
767
+ type: nic.type,
768
+ duplex: nic.duplex,
769
+ mtu: nic.mtu,
770
+ speed: nic.speed,
771
+ dhcp: getDarwinIfaceDHCPstatus(nic.iface),
772
+ dnsSuffix: '',
773
+ ieee8021xAuth: '',
774
+ ieee8021xState: '',
775
+ carrierChanges: 0
776
+ });
763
777
  });
764
- });
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 = [];
778
+ _networkInterfaces = result;
779
+ if (defaultString.toLowerCase().indexOf('default') >= 0) {
780
+ result = result.filter(item => item.default);
781
+ if (result.length > 0) {
782
+ result = result[0];
783
+ } else {
784
+ result = [];
785
+ }
772
786
  }
787
+ if (callback) { callback(result); }
788
+ resolve(result);
773
789
  }
774
- if (callback) { callback(result); }
775
- resolve(result);
776
790
  }
777
791
  if (_linux) {
778
792
  if ((JSON.stringify(ifaces) === JSON.stringify(_ifaces)) && !rescan) {
@@ -784,6 +798,7 @@ function networkInterfaces(callback, rescan, defaultString) {
784
798
  } else {
785
799
  _ifaces = JSON.parse(JSON.stringify(ifaces));
786
800
  _dhcpNics = getLinuxDHCPNics();
801
+ const defaultInterface = getDefaultNetworkInterface();
787
802
  for (let dev in ifaces) {
788
803
  let ip4 = '';
789
804
  let ip4subnet = '';
@@ -803,11 +818,11 @@ function networkInterfaces(callback, rescan, defaultString) {
803
818
  if ({}.hasOwnProperty.call(ifaces, dev)) {
804
819
  let ifaceName = dev;
805
820
  ifaces[dev].forEach(function (details) {
806
- if (details.family === 'IPv4') {
821
+ if (details.family === 'IPv4' || details.family === 4) {
807
822
  ip4 = details.address;
808
823
  ip4subnet = details.netmask;
809
824
  }
810
- if (details.family === 'IPv6') {
825
+ if (details.family === 'IPv6' || details.family === 6) {
811
826
  if (!ip6 || ip6.match(/^fe80::/i)) {
812
827
  ip6 = details.address;
813
828
  ip6subnet = details.netmask;
@@ -927,6 +942,7 @@ function networkInterfaces(callback, rescan, defaultString) {
927
942
  resolve(result);
928
943
  } else {
929
944
  _ifaces = JSON.parse(JSON.stringify(ifaces));
945
+ const defaultInterface = getDefaultNetworkInterface();
930
946
 
931
947
  getWindowsNics().then(function (nics) {
932
948
  nics.forEach(nic => {
@@ -968,11 +984,11 @@ function networkInterfaces(callback, rescan, defaultString) {
968
984
  if ({}.hasOwnProperty.call(ifaces, dev)) {
969
985
  let ifaceName = dev;
970
986
  ifaces[dev].forEach(function (details) {
971
- if (details.family === 'IPv4') {
987
+ if (details.family === 'IPv4' || details.family === 4) {
972
988
  ip4 = details.address;
973
989
  ip4subnet = details.netmask;
974
990
  }
975
- if (details.family === 'IPv6') {
991
+ if (details.family === 'IPv6' || details.family === 6) {
976
992
  if (!ip6 || ip6.match(/^fe80::/i)) {
977
993
  ip6 = details.address;
978
994
  ip6subnet = details.netmask;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.11.12",
3
+ "version": "5.11.15",
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)",