code cleanup
This commit is contained in:
parent
de84c26987
commit
9a5b27c4d3
@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
|
||||
|
||||
| Version | Date | Comment |
|
||||
| -------------- | -------------- | -------- |
|
||||
| 4.17.3 | 2020-01-05 | code cleanup |
|
||||
| 4.17.2 | 2020-01-05 | `cpu().speed` AMD base frequency and fix (0.00) |
|
||||
| 4.17.1 | 2020-01-04 | `fsSize()` alpine linux support |
|
||||
| 4.17.0 | 2020-01-04 | `networkInterfaces()` added dhcp, dnsSuffix, ieee8021xAuth, ieee8021xState |
|
||||
|
||||
@ -83,6 +83,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">4.17.3</th>
|
||||
<td>2020-01-05</td>
|
||||
<td>code cleanup</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">4.17.2</th>
|
||||
<td>2020-01-05</td>
|
||||
|
||||
@ -168,7 +168,7 @@
|
||||
<img class="logo" src="assets/logo.png">
|
||||
<div class="title">systeminformation</div>
|
||||
<div class="subtitle"><span id="typed"></span></div>
|
||||
<div class="version">Current Version: <span id="version">4.17.2</span></div>
|
||||
<div class="version">Current Version: <span id="version">4.17.3</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>
|
||||
</div>
|
||||
<div class="down">
|
||||
|
||||
@ -66,7 +66,6 @@ const AMDBaseFrequencies = {
|
||||
'2373': '2.1',
|
||||
'2374': '2.2',
|
||||
'2376': '2.3',
|
||||
'2376': '2.3',
|
||||
'2377': '2.3',
|
||||
'2378': '2.4',
|
||||
'2379': '2.4',
|
||||
@ -366,7 +365,7 @@ function cpuBrandManufacturer(res) {
|
||||
function getAMDSpeed(brand) {
|
||||
let result = '0.00';
|
||||
for (let key in AMDBaseFrequencies) {
|
||||
if (AMDBaseFrequencies.hasOwnProperty(key)) {
|
||||
if ({}.hasOwnProperty.call(AMDBaseFrequencies, key)) {
|
||||
let parts = key.split('|');
|
||||
let found = 0;
|
||||
parts.forEach(item => {
|
||||
@ -695,7 +694,7 @@ function getCpuCurrentSpeedSync() {
|
||||
|
||||
if (cpus.length) {
|
||||
for (let i in cpus) {
|
||||
if (cpus.hasOwnProperty(i)) {
|
||||
if ({}.hasOwnProperty.call(cpus, i)) {
|
||||
avgFreq = avgFreq + cpus[i].speed;
|
||||
if (cpus[i].speed > maxFreq) maxFreq = cpus[i].speed;
|
||||
if (cpus[i].speed < minFreq) minFreq = cpus[i].speed;
|
||||
|
||||
@ -126,7 +126,7 @@ function dockerContainers(all, callback) {
|
||||
if (docker_containers && Object.prototype.toString.call(docker_containers) === '[object Array]' && docker_containers.length > 0) {
|
||||
// GC in _docker_container_stats
|
||||
for (let key in _docker_container_stats) {
|
||||
if (_docker_container_stats.hasOwnProperty(key)) {
|
||||
if ({}.hasOwnProperty.call(_docker_container_stats, key)) {
|
||||
if (!inContainers(docker_containers, key)) delete _docker_container_stats[key];
|
||||
}
|
||||
}
|
||||
@ -166,7 +166,7 @@ function dockerContainers(all, callback) {
|
||||
} catch (err) {
|
||||
// GC in _docker_container_stats
|
||||
for (let key in _docker_container_stats) {
|
||||
if (_docker_container_stats.hasOwnProperty(key)) {
|
||||
if ({}.hasOwnProperty.call(_docker_container_stats, key)) {
|
||||
if (!inContainers(docker_containers, key)) delete _docker_container_stats[key];
|
||||
}
|
||||
}
|
||||
@ -273,7 +273,7 @@ function docker_calcNetworkIO(networks) {
|
||||
let tx;
|
||||
for (let key in networks) {
|
||||
// skip loop if the property is from prototype
|
||||
if (!networks.hasOwnProperty(key)) continue;
|
||||
if (!{}.hasOwnProperty.call(networks, key)) continue;
|
||||
|
||||
/**
|
||||
* @namespace
|
||||
|
||||
@ -744,7 +744,7 @@ function diskLayout(callback) {
|
||||
let devices = [];
|
||||
try {
|
||||
const outJSON = JSON.parse(out);
|
||||
if (outJSON && outJSON.hasOwnProperty('blockdevices')) {
|
||||
if (outJSON && {}.hasOwnProperty.call(outJSON, 'blockdevices')) {
|
||||
devices = outJSON.blockdevices.filter(item => { return item.group === 'disk' && item.size > 0 && item.model !== null; });
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@ -648,7 +648,7 @@ function graphics(callback) {
|
||||
function parseLinesWindowsControllers(sections) {
|
||||
let controllers = [];
|
||||
for (let i in sections) {
|
||||
if (sections.hasOwnProperty(i)) {
|
||||
if ({}.hasOwnProperty.call(sections, i)) {
|
||||
if (sections[i].trim() !== '') {
|
||||
|
||||
let lines = sections[i].trim().split('\r\n');
|
||||
|
||||
@ -296,7 +296,7 @@ function getAllData(srv, iface, callback) {
|
||||
data = res;
|
||||
getDynamicData(srv, iface).then(res => {
|
||||
for (let key in res) {
|
||||
if (res.hasOwnProperty(key)) {
|
||||
if ({}.hasOwnProperty.call(res, key)) {
|
||||
data[key] = res[key];
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,7 +263,7 @@ exports.mem = mem;
|
||||
function memLayout(callback) {
|
||||
|
||||
function getManufacturer(manId) {
|
||||
if (OSX_RAM_manufacturers.hasOwnProperty(manId)) {
|
||||
if ({}.hasOwnProperty.call(OSX_RAM_manufacturers, manId)) {
|
||||
return (OSX_RAM_manufacturers[manId]);
|
||||
}
|
||||
return manId;
|
||||
|
||||
@ -46,7 +46,7 @@ function getDefaultNetworkInterface() {
|
||||
|
||||
// fallback - "first" external interface (sorted by scopeid)
|
||||
for (let dev in ifaces) {
|
||||
if (ifaces.hasOwnProperty(dev)) {
|
||||
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
||||
ifaces[dev].forEach(function (details) {
|
||||
if (details && details.internal === false) {
|
||||
ifacenameFirst = ifacenameFirst || dev; // fallback if no scopeid
|
||||
@ -77,7 +77,7 @@ function getDefaultNetworkInterface() {
|
||||
});
|
||||
if (defaultIp) {
|
||||
for (let dev in ifaces) {
|
||||
if (ifaces.hasOwnProperty(dev)) {
|
||||
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
||||
ifaces[dev].forEach(function (details) {
|
||||
if (details && details.address && details.address === defaultIp) {
|
||||
ifacename = dev;
|
||||
@ -186,7 +186,7 @@ exports.networkInterfaceDefault = networkInterfaceDefault;
|
||||
function parseLinesWindowsNics(sections, nconfigsections) {
|
||||
let nics = [];
|
||||
for (let i in sections) {
|
||||
if (sections.hasOwnProperty(i)) {
|
||||
if ({}.hasOwnProperty.call(sections, i)) {
|
||||
|
||||
if (sections[i].trim() !== '') {
|
||||
|
||||
@ -244,19 +244,19 @@ function getWindowsDNSsuffixes() {
|
||||
const longPrimaryDNS = element.split('\r\n').filter((element) => {
|
||||
return element.toUpperCase().includes('DNS');
|
||||
});
|
||||
const primaryDNS = longPrimaryDNS[0].substring(longPrimaryDNS[0].lastIndexOf(":") + 1);
|
||||
const primaryDNS = longPrimaryDNS[0].substring(longPrimaryDNS[0].lastIndexOf(':') + 1);
|
||||
dnsSuffixes.primaryDNS = primaryDNS.trim();
|
||||
if (!dnsSuffixes.primaryDNS) dnsSuffixes.primaryDNS = 'Not defined';
|
||||
}
|
||||
if (index > 1) {
|
||||
if (index % 2 == 0) {
|
||||
const name = element.substring(element.lastIndexOf(" ") + 1).replace(':', '');
|
||||
const name = element.substring(element.lastIndexOf(' ') + 1).replace(':', '');
|
||||
iface.name = name;
|
||||
} else {
|
||||
const connectionSpecificDNS = element.split('\r\n').filter((element) => {
|
||||
return element.toUpperCase().includes('DNS')
|
||||
return element.toUpperCase().includes('DNS');
|
||||
});
|
||||
const dnsSuffix = connectionSpecificDNS[0].substring(connectionSpecificDNS[0].lastIndexOf(":") + 1);
|
||||
const dnsSuffix = connectionSpecificDNS[0].substring(connectionSpecificDNS[0].lastIndexOf(':') + 1);
|
||||
iface.dnsSuffix = dnsSuffix.trim();
|
||||
dnsSuffixes.ifaces.push(iface);
|
||||
iface = {};
|
||||
@ -273,7 +273,6 @@ function getWindowsDNSsuffixes() {
|
||||
ifaces: [],
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getWindowsIfaceDNSsuffix(ifaces, ifacename) {
|
||||
@ -325,8 +324,8 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) {
|
||||
};
|
||||
|
||||
if (ifaces === 'Disabled') {
|
||||
i8021x.state = "Disabled";
|
||||
i8021x.protocol = "Not defined";
|
||||
i8021x.state = 'Disabled';
|
||||
i8021x.protocol = 'Not defined';
|
||||
return i8021x;
|
||||
}
|
||||
|
||||
@ -342,14 +341,14 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) {
|
||||
});
|
||||
|
||||
if (state8021x.includes('Disabled')) {
|
||||
i8021x.state = "Disabled";
|
||||
i8021x.protocol = "Not defined";
|
||||
i8021x.state = 'Disabled';
|
||||
i8021x.protocol = 'Not defined';
|
||||
} else if (state8021x.includes('Enabled')) {
|
||||
const protocol8021x = arrayIface8021xInfo.find((element) => {
|
||||
return element.includes('EAP');
|
||||
});
|
||||
i8021x.protocol = protocol8021x.split(':').pop();
|
||||
i8021x.state = "Enabled";
|
||||
i8021x.state = 'Enabled';
|
||||
}
|
||||
} catch (error) {
|
||||
// console.log('Error getting wired information:', error);
|
||||
@ -376,8 +375,8 @@ function getWindowsIEEE8021x(connectionType, iface, ifaces) {
|
||||
} catch (error) {
|
||||
// console.log('Error getting wireless information:', error);
|
||||
if (error.status === 1 && error.stdout.includes('AutoConfig')) {
|
||||
i8021x.state = "Disabled";
|
||||
i8021x.protocol = "Not defined";
|
||||
i8021x.state = 'Disabled';
|
||||
i8021x.protocol = 'Not defined';
|
||||
}
|
||||
return i8021x;
|
||||
}
|
||||
@ -472,14 +471,13 @@ function getDarwinNics() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getLinuxIfaceConnectionName(interfaceName) {
|
||||
const cmd = `nmcli device status 2>/dev/null | grep ${interfaceName}`;
|
||||
|
||||
try {
|
||||
const result = execSync(cmd).toString();
|
||||
const resultFormat = result.replace(/\s+/g, ' ').trim();
|
||||
const connectionNameLines = resultFormat.split(" ").slice(3);
|
||||
const connectionNameLines = resultFormat.split(' ').slice(3);
|
||||
const connectionName = connectionNameLines.join(' ');
|
||||
return connectionName != '--' ? connectionName : '';
|
||||
} catch (e) {
|
||||
@ -492,18 +490,18 @@ function getLinuxIfaceDHCPstatus(connectionName) {
|
||||
if (connectionName) {
|
||||
const cmd = `nmcli connection show "${connectionName}" 2>/dev/null \| grep ipv4.method;`;
|
||||
try {
|
||||
const result = execSync(cmd).toString();
|
||||
const resultFormat = result.replace(/\s+/g, ' ').trim();
|
||||
const lines = execSync(cmd).toString();
|
||||
const resultFormat = lines.replace(/\s+/g, ' ').trim();
|
||||
|
||||
let dhcStatus = resultFormat.split(" ").slice(1).toString();
|
||||
let dhcStatus = resultFormat.split(' ').slice(1).toString();
|
||||
switch (dhcStatus) {
|
||||
case 'auto':
|
||||
result = true;
|
||||
break;
|
||||
case 'auto':
|
||||
result = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
result = false;
|
||||
break;
|
||||
default:
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
} catch (e) {
|
||||
@ -520,7 +518,7 @@ function getLinuxIfaceDNSsuffix(connectionName) {
|
||||
try {
|
||||
const result = execSync(cmd).toString();
|
||||
const resultFormat = result.replace(/\s+/g, ' ').trim();
|
||||
const dnsSuffix = resultFormat.split(" ").slice(1).toString();
|
||||
const dnsSuffix = resultFormat.split(' ').slice(1).toString();
|
||||
return dnsSuffix == '--' ? 'Not defined' : dnsSuffix;
|
||||
} catch (e) {
|
||||
return 'Unknown';
|
||||
@ -536,7 +534,7 @@ function getLinuxIfaceIEEE8021xAuth(connectionName) {
|
||||
try {
|
||||
const result = execSync(cmd).toString();
|
||||
const resultFormat = result.replace(/\s+/g, ' ').trim();
|
||||
const authenticationProtocol = resultFormat.split(" ").slice(1).toString();
|
||||
const authenticationProtocol = resultFormat.split(' ').slice(1).toString();
|
||||
|
||||
|
||||
return authenticationProtocol == '--' ? '' : authenticationProtocol;
|
||||
@ -640,7 +638,7 @@ function networkInterfaces(callback) {
|
||||
let ieee8021xState = '';
|
||||
let type = '';
|
||||
|
||||
if (ifaces.hasOwnProperty(dev)) {
|
||||
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
||||
let ifaceName = dev;
|
||||
ifaces[dev].forEach(function (details) {
|
||||
if (details.family === 'IPv4') {
|
||||
@ -869,9 +867,8 @@ function networkStatsSingle(iface) {
|
||||
function parseLinesWindowsPerfData(sections) {
|
||||
let perfData = [];
|
||||
for (let i in sections) {
|
||||
if (sections.hasOwnProperty(i)) {
|
||||
if ({}.hasOwnProperty.call(sections, i)) {
|
||||
if (sections[i].trim() !== '') {
|
||||
|
||||
let lines = sections[i].trim().split('\r\n');
|
||||
perfData.push({
|
||||
name: util.getValue(lines, 'Name', '=').replace(/[()\[\] ]+/g, '').toLowerCase(),
|
||||
|
||||
@ -65,7 +65,7 @@ function unique(obj) {
|
||||
str += JSON.stringify(keys[j]);
|
||||
str += JSON.stringify(obj[i][keys[j]]);
|
||||
}
|
||||
if (!stringify.hasOwnProperty(str)) {
|
||||
if (!{}.hasOwnProperty.call(stringify, str)) {
|
||||
uniques.push(obj[i]);
|
||||
stringify[str] = true;
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ function wifiFrequencyFromChannel(channel) {
|
||||
192: 4960,
|
||||
196: 4980
|
||||
};
|
||||
return frequencies.hasOwnProperty(channel) ? frequencies[channel] : -1;
|
||||
return {}.hasOwnProperty.call(frequencies, channel) ? frequencies[channel] : -1;
|
||||
}
|
||||
|
||||
function wifiNetworks(callback) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user