etworkStats() improved scanning (mac OS)
This commit is contained in:
parent
2c4d96a72e
commit
d446b8d9e4
@ -80,6 +80,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| -------------- | -------------- | -------- |
|
| -------------- | -------------- | -------- |
|
||||||
|
| 5.11.13 | 2022-04-21 | `etworkStats()` improved scanning (mac OS) |
|
||||||
| 5.11.12 | 2022-04-19 | `battery()` improved M1 support (mac OS) |
|
| 5.11.12 | 2022-04-19 | `battery()` improved M1 support (mac OS) |
|
||||||
| 5.11.11 | 2022-04-19 | `networkInterfaces()` improved parsing (windows) |
|
| 5.11.11 | 2022-04-19 | `networkInterfaces()` improved parsing (windows) |
|
||||||
| 5.11.10 | 2022-04-18 | updated docs |
|
| 5.11.10 | 2022-04-18 | updated docs |
|
||||||
|
|||||||
@ -57,6 +57,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">5.11.13</th>
|
||||||
|
<td>2022-04-21</td>
|
||||||
|
<td><span class="code">networkStats()</span> improved scanning (mac OS)</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">5.11.12</th>
|
<th scope="row">5.11.12</th>
|
||||||
<td>2022-04-19</td>
|
<td>2022-04-19</td>
|
||||||
|
|||||||
@ -170,7 +170,7 @@
|
|||||||
<img class="logo" src="assets/logo.png">
|
<img class="logo" src="assets/logo.png">
|
||||||
<div class="title">systeminformation</div>
|
<div class="title">systeminformation</div>
|
||||||
<div class="subtitle"><span id="typed"></span> </div>
|
<div class="subtitle"><span id="typed"></span> </div>
|
||||||
<div class="version">New Version: <span id="version">5.11.12</span></div>
|
<div class="version">New Version: <span id="version">5.11.13</span></div>
|
||||||
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
|
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="down">
|
<div class="down">
|
||||||
|
|||||||
@ -185,7 +185,7 @@ module.exports = function (callback) {
|
|||||||
result.voltage = parseInt('0' + util.getValue(lines, 'voltage', '='), 10) / 1000.0;
|
result.voltage = parseInt('0' + util.getValue(lines, 'voltage', '='), 10) / 1000.0;
|
||||||
result.capacityUnit = result.voltage ? 'mWh' : 'mAh';
|
result.capacityUnit = result.voltage ? 'mWh' : 'mAh';
|
||||||
result.maxCapacity = Math.round(parseInt('0' + util.getValue(lines, 'applerawmaxcapacity', '='), 10) * (result.voltage || 1));
|
result.maxCapacity = Math.round(parseInt('0' + util.getValue(lines, 'applerawmaxcapacity', '='), 10) * (result.voltage || 1));
|
||||||
result.currentCapacity = Math.round(parseInt('0' + util.getValue(lines, 'applerawxcurrentcapacity', '='), 10) * (result.voltage || 1));
|
result.currentCapacity = Math.round(parseInt('0' + util.getValue(lines, 'applerawcurrentcapacity', '='), 10) * (result.voltage || 1));
|
||||||
result.designedCapacity = Math.round(parseInt('0' + util.getValue(lines, 'DesignCapacity', '='), 10) * (result.voltage || 1));
|
result.designedCapacity = Math.round(parseInt('0' + util.getValue(lines, 'DesignCapacity', '='), 10) * (result.voltage || 1));
|
||||||
result.manufacturer = 'Apple';
|
result.manufacturer = 'Apple';
|
||||||
result.serial = util.getValue(lines, 'BatterySerialNumber', '=');
|
result.serial = util.getValue(lines, 'BatterySerialNumber', '=');
|
||||||
|
|||||||
@ -108,6 +108,7 @@ function getDefaultNetworkInterface() {
|
|||||||
if (_linux) { cmd = 'ip route 2> /dev/null | grep default | awk \'{print $5}\''; }
|
if (_linux) { cmd = 'ip route 2> /dev/null | grep default | awk \'{print $5}\''; }
|
||||||
if (_darwin) { cmd = 'route -n get default 2>/dev/null | grep interface: | awk \'{print $2}\''; }
|
if (_darwin) { cmd = 'route -n get default 2>/dev/null | grep interface: | awk \'{print $2}\''; }
|
||||||
if (_freebsd || _openbsd || _netbsd || _sunos) { cmd = 'route get 0.0.0.0 | grep interface:'; }
|
if (_freebsd || _openbsd || _netbsd || _sunos) { cmd = 'route get 0.0.0.0 | grep interface:'; }
|
||||||
|
// console.log('SYNC - default darwin 3');
|
||||||
let result = execSync(cmd);
|
let result = execSync(cmd);
|
||||||
ifacename = result.toString().split('\n')[0];
|
ifacename = result.toString().split('\n')[0];
|
||||||
if (ifacename.indexOf(':') > -1) {
|
if (ifacename.indexOf(':') > -1) {
|
||||||
@ -172,6 +173,7 @@ function getMacAddresses() {
|
|||||||
if (_darwin) {
|
if (_darwin) {
|
||||||
try {
|
try {
|
||||||
const cmd = '/sbin/ifconfig';
|
const cmd = '/sbin/ifconfig';
|
||||||
|
// console.log('SYNC - macAde darwin 6');
|
||||||
let res = execSync(cmd);
|
let res = execSync(cmd);
|
||||||
const lines = res.toString().split('\n');
|
const lines = res.toString().split('\n');
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
@ -504,6 +506,7 @@ function parseLinesDarwinNics(sections) {
|
|||||||
function getDarwinNics() {
|
function getDarwinNics() {
|
||||||
const cmd = '/sbin/ifconfig -v';
|
const cmd = '/sbin/ifconfig -v';
|
||||||
try {
|
try {
|
||||||
|
// console.log('SYNC - Nics darwin 12');
|
||||||
const lines = execSync(cmd, { maxBuffer: 1024 * 20000 }).toString().split('\n');
|
const lines = execSync(cmd, { maxBuffer: 1024 * 20000 }).toString().split('\n');
|
||||||
const nsections = splitSectionsNics(lines);
|
const nsections = splitSectionsNics(lines);
|
||||||
return (parseLinesDarwinNics(nsections));
|
return (parseLinesDarwinNics(nsections));
|
||||||
@ -622,6 +625,7 @@ function getDarwinIfaceDHCPstatus(iface) {
|
|||||||
let result = false;
|
let result = false;
|
||||||
const cmd = `ipconfig getpacket "${iface}" 2>/dev/null | grep lease_time;`;
|
const cmd = `ipconfig getpacket "${iface}" 2>/dev/null | grep lease_time;`;
|
||||||
try {
|
try {
|
||||||
|
// console.log('SYNC - DHCP status darwin 17');
|
||||||
const lines = execSync(cmd).toString().split('\n');
|
const lines = execSync(cmd).toString().split('\n');
|
||||||
if (lines.length && lines[0].startsWith('lease_time')) {
|
if (lines.length && lines[0].startsWith('lease_time')) {
|
||||||
result = true;
|
result = true;
|
||||||
@ -713,7 +717,6 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
const defaultInterface = getDefaultNetworkInterface();
|
|
||||||
|
|
||||||
let ifaces = os.networkInterfaces();
|
let ifaces = os.networkInterfaces();
|
||||||
|
|
||||||
@ -723,6 +726,16 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|||||||
let nics8021xInfo = [];
|
let nics8021xInfo = [];
|
||||||
// seperate handling in OSX
|
// seperate handling in OSX
|
||||||
if (_darwin || _freebsd || _openbsd || _netbsd) {
|
if (_darwin || _freebsd || _openbsd || _netbsd) {
|
||||||
|
if ((JSON.stringify(ifaces) === JSON.stringify(_ifaces)) && !rescan) {
|
||||||
|
// no changes - just return object
|
||||||
|
result = _networkInterfaces;
|
||||||
|
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
} else {
|
||||||
|
const defaultInterface = getDefaultNetworkInterface();
|
||||||
|
_ifaces = JSON.parse(JSON.stringify(ifaces));
|
||||||
|
|
||||||
nics = getDarwinNics();
|
nics = getDarwinNics();
|
||||||
|
|
||||||
|
|
||||||
@ -774,6 +787,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|||||||
if (callback) { callback(result); }
|
if (callback) { callback(result); }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (_linux) {
|
if (_linux) {
|
||||||
if ((JSON.stringify(ifaces) === JSON.stringify(_ifaces)) && !rescan) {
|
if ((JSON.stringify(ifaces) === JSON.stringify(_ifaces)) && !rescan) {
|
||||||
// no changes - just return object
|
// no changes - just return object
|
||||||
@ -784,6 +798,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|||||||
} else {
|
} else {
|
||||||
_ifaces = JSON.parse(JSON.stringify(ifaces));
|
_ifaces = JSON.parse(JSON.stringify(ifaces));
|
||||||
_dhcpNics = getLinuxDHCPNics();
|
_dhcpNics = getLinuxDHCPNics();
|
||||||
|
const defaultInterface = getDefaultNetworkInterface();
|
||||||
for (let dev in ifaces) {
|
for (let dev in ifaces) {
|
||||||
let ip4 = '';
|
let ip4 = '';
|
||||||
let ip4subnet = '';
|
let ip4subnet = '';
|
||||||
@ -927,6 +942,7 @@ function networkInterfaces(callback, rescan, defaultString) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
} else {
|
} else {
|
||||||
_ifaces = JSON.parse(JSON.stringify(ifaces));
|
_ifaces = JSON.parse(JSON.stringify(ifaces));
|
||||||
|
const defaultInterface = getDefaultNetworkInterface();
|
||||||
|
|
||||||
getWindowsNics().then(function (nics) {
|
getWindowsNics().then(function (nics) {
|
||||||
nics.forEach(nic => {
|
nics.forEach(nic => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user