Merge branch 'master' of https://github.com/sebhildebrandt/systeminformation
This commit is contained in:
commit
de35fafb3a
@ -163,6 +163,7 @@ Full function reference with examples can be found at [https://systeminformation
|
||||
| | version | X | X | X | X | | version |
|
||||
| | releaseDate | X | X | | X | | release date |
|
||||
| | revision | X | X | | X | | revision |
|
||||
| | serial | X | | | X | | serial |
|
||||
| si.baseboard(cb) | {...} | X | X | X | X | | baseboard information |
|
||||
| | manufacturer | X | X | X | X | | e.g. 'ASUS' |
|
||||
| | model | X | X | X | X | | model / product name |
|
||||
|
||||
@ -205,7 +205,7 @@
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>MUT maximum transmission unit</td>
|
||||
<td>MTU maximum transmission unit</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
|
||||
@ -293,6 +293,16 @@ si.uuid().then(data => console.log(data));</code></pre class="example">
|
||||
<td></td>
|
||||
<td>revision</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>serial</td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>serial</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>language</td>
|
||||
|
||||
@ -160,7 +160,7 @@ module.exports = function (callback) {
|
||||
}
|
||||
}
|
||||
if (_freebsd || _openbsd || _netbsd) {
|
||||
exec('sysctl hw.acpi.battery hw.acpi.acline', function (error, stdout) {
|
||||
exec('sysctl -i hw.acpi.battery hw.acpi.acline', function (error, stdout) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
const batteries = parseInt('0' + util.getValue(lines, 'hw.acpi.battery.units'), 10);
|
||||
const percent = parseInt('0' + util.getValue(lines, 'hw.acpi.battery.life'), 10);
|
||||
|
||||
@ -126,24 +126,28 @@ function fsSize(callback) {
|
||||
}
|
||||
if (_windows) {
|
||||
try {
|
||||
util.wmic('logicaldisk get Caption,FileSystem,FreeSpace,Size').then((stdout) => {
|
||||
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
|
||||
lines.forEach(function (line) {
|
||||
if (line !== '') {
|
||||
line = line.trim().split(/\s\s+/);
|
||||
if (line.length >= 4 && parseInt(line[3], 10)) {
|
||||
// util.wmic('logicaldisk get Caption,FileSystem,FreeSpace,Size').then((stdout) => {
|
||||
util.powerShell('Get-WmiObject Win32_logicaldisk | fl *').then((stdout, error) => {
|
||||
if (!error) {
|
||||
let devices = stdout.toString().split(/\n\s*\n/);
|
||||
devices.forEach(function (device) {
|
||||
let lines = device.split('\r\n');
|
||||
const size = util.toInt(util.getValue(lines, 'size', ':'));
|
||||
const free = util.toInt(util.getValue(lines, 'freespace', ':'));
|
||||
const caption = util.getValue(lines, 'caption', ':');
|
||||
if (size) {
|
||||
data.push({
|
||||
fs: line[0],
|
||||
type: line[1],
|
||||
size: parseInt(line[3], 10),
|
||||
used: parseInt(line[3], 10) - parseInt(line[2], 10),
|
||||
available: parseInt(line[2], 10),
|
||||
use: parseFloat(((100.0 * (parseInt(line[3]) - parseInt(line[2]))) / parseInt(line[3])).toFixed(2)),
|
||||
mount: line[0]
|
||||
fs: caption,
|
||||
type: util.getValue(lines, 'filesystem', ':'),
|
||||
size,
|
||||
used: size - free,
|
||||
available: free,
|
||||
use: parseFloat(((100.0 * (size - free)) / size).toFixed(2)),
|
||||
mount: caption
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (callback) {
|
||||
callback(data);
|
||||
}
|
||||
@ -173,12 +177,12 @@ function fsOpenFiles(callback) {
|
||||
available: null
|
||||
};
|
||||
if (_freebsd || _openbsd || _netbsd || _darwin) {
|
||||
let cmd = 'sysctl -a | grep \'kern.*files\'';
|
||||
let cmd = 'sysctl -i kern.maxfiles kern.num_files kern.open_files';
|
||||
exec(cmd, { maxBuffer: 1024 * 1024 }, function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
result.max = parseInt(util.getValue(lines, 'kern.maxfiles', ':'), 10);
|
||||
result.allocated = parseInt(util.getValue(lines, 'kern.num_files', ':'), 10);
|
||||
result.allocated = parseInt(util.getValue(lines, 'kern.num_files', ':'), 10) || parseInt(util.getValue(lines, 'kern.open_files', ':'), 10);
|
||||
result.available = result.max - result.allocated;
|
||||
}
|
||||
if (callback) {
|
||||
@ -776,37 +780,37 @@ function diskLayout(callback) {
|
||||
|
||||
function getVendorFromModel(model) {
|
||||
const diskManufacturers = [
|
||||
{ pattern: '^WESTERN.+', manufacturer: 'Western Digital' },
|
||||
{ pattern: '^WDC.+', manufacturer: 'Western Digital' },
|
||||
{ pattern: 'WD.+', manufacturer: 'Western Digital' },
|
||||
{ pattern: '^TOSHIBA.+', manufacturer: 'Toshiba' },
|
||||
{ pattern: '^HITACHI.+', manufacturer: 'Hitachi' },
|
||||
{ pattern: '^IC.+', manufacturer: 'Hitachi' },
|
||||
{ pattern: '^HTS.+', manufacturer: 'Hitachi' },
|
||||
{ pattern: '^SANDISK.+', manufacturer: 'SanDisk' },
|
||||
{ pattern: '^KINGSTON.+', manufacturer: 'Kingston Technology' },
|
||||
{ pattern: '^SONY.+', manufacturer: 'Sony' },
|
||||
{ pattern: '^TRANSCEND.+', manufacturer: 'Transcend' },
|
||||
{ pattern: 'SAMSUNG.+', manufacturer: 'Samsung' },
|
||||
{ pattern: '^ST(?!I\\ ).+', manufacturer: 'Seagate' },
|
||||
{ pattern: '^STI\\ .+', manufacturer: 'SimpleTech' },
|
||||
{ pattern: '^D...-.+', manufacturer: 'IBM' },
|
||||
{ pattern: '^IBM.+', manufacturer: 'IBM' },
|
||||
{ pattern: '^FUJITSU.+', manufacturer: 'Fujitsu' },
|
||||
{ pattern: '^MP.+', manufacturer: 'Fujitsu' },
|
||||
{ pattern: '^MK.+', manufacturer: 'Toshiba' },
|
||||
{ pattern: '^MAXTOR.+', manufacturer: 'Maxtor' },
|
||||
{ pattern: '^Pioneer.+', manufacturer: 'Pioneer' },
|
||||
{ pattern: '^PHILIPS.+', manufacturer: 'Philips' },
|
||||
{ pattern: '^QUANTUM.+', manufacturer: 'Quantum Technology' },
|
||||
{ pattern: 'FIREBALL.+', manufacturer: 'Quantum Technology' },
|
||||
{ pattern: '^VBOX.+', manufacturer: 'VirtualBox' },
|
||||
{ pattern: 'CORSAIR.+', manufacturer: 'Corsair Components' },
|
||||
{ pattern: 'CRUCIAL.+', manufacturer: 'Crucial' },
|
||||
{ pattern: 'ECM.+', manufacturer: 'ECM' },
|
||||
{ pattern: 'INTEL.+', manufacturer: 'INTEL' },
|
||||
{ pattern: '.+EVO', manufacturer: 'Samsung' },
|
||||
{ pattern: 'APPLE.+', manufacturer: 'Apple' },
|
||||
{ pattern: 'WESTERN.*', manufacturer: 'Western Digital' },
|
||||
{ pattern: '^WDC.*', manufacturer: 'Western Digital' },
|
||||
{ pattern: 'WD.*', manufacturer: 'Western Digital' },
|
||||
{ pattern: 'TOSHIBA.*', manufacturer: 'Toshiba' },
|
||||
{ pattern: 'HITACHI.*', manufacturer: 'Hitachi' },
|
||||
{ pattern: '^IC.*', manufacturer: 'Hitachi' },
|
||||
{ pattern: '^HTS.*', manufacturer: 'Hitachi' },
|
||||
{ pattern: 'SANDISK.*', manufacturer: 'SanDisk' },
|
||||
{ pattern: 'KINGSTON.*', manufacturer: 'Kingston Technology' },
|
||||
{ pattern: '^SONY.*', manufacturer: 'Sony' },
|
||||
{ pattern: 'TRANSCEND.*', manufacturer: 'Transcend' },
|
||||
{ pattern: 'SAMSUNG.*', manufacturer: 'Samsung' },
|
||||
{ pattern: '^ST(?!I\\ ).*', manufacturer: 'Seagate' },
|
||||
{ pattern: '^STI\\ .*', manufacturer: 'SimpleTech' },
|
||||
{ pattern: '^D...-.*', manufacturer: 'IBM' },
|
||||
{ pattern: '^IBM.*', manufacturer: 'IBM' },
|
||||
{ pattern: '^FUJITSU.*', manufacturer: 'Fujitsu' },
|
||||
{ pattern: '^MP.*', manufacturer: 'Fujitsu' },
|
||||
{ pattern: '^MK.*', manufacturer: 'Toshiba' },
|
||||
{ pattern: 'MAXTO.*', manufacturer: 'Maxtor' },
|
||||
{ pattern: 'PIONEER.*', manufacturer: 'Pioneer' },
|
||||
{ pattern: 'PHILIPS.*', manufacturer: 'Philips' },
|
||||
{ pattern: 'QUANTUM.*', manufacturer: 'Quantum Technology' },
|
||||
{ pattern: 'FIREBALL.*', manufacturer: 'Quantum Technology' },
|
||||
{ pattern: '^VBOX.*', manufacturer: 'VirtualBox' },
|
||||
{ pattern: 'CORSAIR.*', manufacturer: 'Corsair Components' },
|
||||
{ pattern: 'CRUCIAL.*', manufacturer: 'Crucial' },
|
||||
{ pattern: 'ECM.*', manufacturer: 'ECM' },
|
||||
{ pattern: 'INTEL.*', manufacturer: 'INTEL' },
|
||||
{ pattern: 'EVO.*', manufacturer: 'Samsung' },
|
||||
{ pattern: 'APPLE.*', manufacturer: 'Apple' },
|
||||
];
|
||||
|
||||
let result = '';
|
||||
|
||||
@ -181,7 +181,7 @@ function graphics(callback) {
|
||||
connection: ((connectionType.indexOf('_internal') > -1) ? 'Internal' : ((connectionType.indexOf('_displayport') > -1) ? 'Display Port' : ((connectionType.indexOf('_hdmi') > -1) ? 'HDMI' : null))),
|
||||
sizeX: null,
|
||||
sizeY: null,
|
||||
pixelDepth: (pixelDepthString === 'CGSThirtyBitColor' ? 30 : (pixelDepthString === 'CGSThirtytwoBitColor' ? 32 : (pixelDepthString === 'CGSTwentyfourBitColor' ? 24 : ''))),
|
||||
pixelDepth: (pixelDepthString === 'CGSThirtyBitColor' ? 30 : (pixelDepthString === 'CGSThirtytwoBitColor' ? 32 : (pixelDepthString === 'CGSTwentyfourBitColor' ? 24 : null))),
|
||||
resolutionX: pixelParts.length > 1 ? parseInt(pixelParts[0], 10) : null,
|
||||
resolutionY: pixelParts.length > 1 ? parseInt(pixelParts[1], 10) : null,
|
||||
currentResX: currentResolution.length > 1 ? parseInt(currentResolution[0], 10) : null,
|
||||
@ -860,7 +860,7 @@ function graphics(callback) {
|
||||
if (_pixelDepth) {
|
||||
result.displays[0].pixelDepth = _pixelDepth;
|
||||
}
|
||||
if (_refreshRate && !result.displays[0].refreshRate) {
|
||||
if (_refreshRate && !result.displays[0].currentRefreshRate) {
|
||||
result.displays[0].currentRefreshRate = _refreshRate;
|
||||
}
|
||||
}
|
||||
|
||||
46
lib/index.d.ts
vendored
46
lib/index.d.ts
vendored
@ -38,6 +38,7 @@ export namespace Systeminformation {
|
||||
version: string;
|
||||
releaseDate: string;
|
||||
revision: string;
|
||||
serial?: string;
|
||||
language?: string;
|
||||
features?: string[];
|
||||
}
|
||||
@ -302,7 +303,7 @@ export namespace Systeminformation {
|
||||
deviceId?: string;
|
||||
bus: string;
|
||||
busAddress?: string;
|
||||
vram: number;
|
||||
vram: number | null;
|
||||
vramDynamic: boolean;
|
||||
external?: boolean;
|
||||
cores?: number;
|
||||
@ -311,6 +312,7 @@ export namespace Systeminformation {
|
||||
driverVersion?: string;
|
||||
name?: string;
|
||||
pciBus?: string;
|
||||
pciID?: string;
|
||||
fanSpeed?: number;
|
||||
memoryTotal?: number;
|
||||
memoryUsed?: number;
|
||||
@ -327,21 +329,25 @@ export namespace Systeminformation {
|
||||
|
||||
interface GraphicsDisplayData {
|
||||
vendor: string;
|
||||
vendorId: string | null;
|
||||
model: string;
|
||||
deviceName: string;
|
||||
productionYear: number | null;
|
||||
serial: string | null;
|
||||
deviceName: string | null;
|
||||
displayId: string | null;
|
||||
main: boolean;
|
||||
builtin: boolean;
|
||||
connection: string;
|
||||
sizeX: number;
|
||||
sizeY: number;
|
||||
pixelDepth: number;
|
||||
resolutionX: number;
|
||||
resolutionY: number;
|
||||
currentResX: number;
|
||||
currentResY: number;
|
||||
connection: string | null;
|
||||
sizeX: number | null;
|
||||
sizeY: number | null;
|
||||
pixelDepth: number | null;
|
||||
resolutionX: number | null;
|
||||
resolutionY: number | null;
|
||||
currentResX: number | null;
|
||||
currentResY: number | null;
|
||||
positionX: number;
|
||||
positionY: number;
|
||||
currentRefreshRate: number;
|
||||
currentRefreshRate: number | null;
|
||||
}
|
||||
|
||||
// 4. Operating System
|
||||
@ -452,9 +458,9 @@ export namespace Systeminformation {
|
||||
rx: number;
|
||||
wx: number;
|
||||
tx: number;
|
||||
rx_sec: number;
|
||||
wx_sec: number;
|
||||
tx_sec: number;
|
||||
rx_sec: number | null;
|
||||
wx_sec: number | null;
|
||||
tx_sec: number | null;
|
||||
ms: number;
|
||||
}
|
||||
|
||||
@ -462,9 +468,15 @@ export namespace Systeminformation {
|
||||
rIO: number;
|
||||
wIO: number;
|
||||
tIO: number;
|
||||
rIO_sec: number;
|
||||
wIO_sec: number;
|
||||
tIO_sec: number;
|
||||
rIO_sec: number | null;
|
||||
wIO_sec: number | null;
|
||||
tIO_sec: number | null;
|
||||
rWaitTime: number;
|
||||
wWaitTime: number;
|
||||
tWaitTime: number;
|
||||
rWaitPercent: number | null;
|
||||
wWaitPercent: number | null;
|
||||
tWaitPercent: number | null;
|
||||
ms: number;
|
||||
}
|
||||
|
||||
|
||||
@ -198,7 +198,7 @@ function mem(callback) {
|
||||
});
|
||||
}
|
||||
if (_freebsd || _openbsd || _netbsd) {
|
||||
exec('/sbin/sysctl -a 2>/dev/null | grep -E "hw.realmem|hw.physmem|vm.stats.vm.v_page_count|vm.stats.vm.v_wire_count|vm.stats.vm.v_active_count|vm.stats.vm.v_inactive_count|vm.stats.vm.v_cache_count|vm.stats.vm.v_free_count|vm.stats.vm.v_page_size"', function (error, stdout) {
|
||||
exec('/sbin/sysctl hw.realmem hw.physmem vm.stats.vm.v_page_count vm.stats.vm.v_wire_count vm.stats.vm.v_active_count vm.stats.vm.v_inactive_count vm.stats.vm.v_cache_count vm.stats.vm.v_free_count vm.stats.vm.v_page_size', function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
const pagesize = parseInt(util.getValue(lines, 'vm.stats.vm.v_page_size'), 10);
|
||||
@ -331,7 +331,7 @@ function memLayout(callback) {
|
||||
serialNum: util.getValue(lines, 'Serial Number:'),
|
||||
voltageConfigured: parseFloat(util.getValue(lines, 'Configured Voltage:')) || null,
|
||||
voltageMin: parseFloat(util.getValue(lines, 'Minimum Voltage:')) || null,
|
||||
voltageMax: parseFloat(util.getValue(lines, 'Maximum Voltage:'))|| null,
|
||||
voltageMax: parseFloat(util.getValue(lines, 'Maximum Voltage:')) || null,
|
||||
});
|
||||
} else {
|
||||
result.push({
|
||||
|
||||
224
lib/network.js
224
lib/network.js
@ -218,23 +218,23 @@ function parseLinesWindowsNics(sections, nconfigsections) {
|
||||
|
||||
let lines = sections[i].trim().split('\r\n');
|
||||
let linesNicConfig = nconfigsections[i].trim().split('\r\n');
|
||||
let netEnabled = util.getValue(lines, 'NetEnabled', '=');
|
||||
let adapterType = util.getValue(lines, 'AdapterTypeID', '=') === '9' ? 'wireless' : 'wired';
|
||||
let ifacename = util.getValue(lines, 'Name', '=').replace(/\]/g, ')').replace(/\[/g, '(');
|
||||
let iface = util.getValue(lines, 'NetConnectionID', '=').replace(/\]/g, ')').replace(/\[/g, '(');
|
||||
let netEnabled = util.getValue(lines, 'NetEnabled', ':');
|
||||
let adapterType = util.getValue(lines, 'AdapterTypeID', ':') === '9' ? 'wireless' : 'wired';
|
||||
let ifacename = util.getValue(lines, 'Name', ':').replace(/\]/g, ')').replace(/\[/g, '(');
|
||||
let iface = util.getValue(lines, 'NetConnectionID', ':').replace(/\]/g, ')').replace(/\[/g, '(');
|
||||
if (ifacename.toLowerCase().indexOf('wi-fi') >= 0 || ifacename.toLowerCase().indexOf('wireless') >= 0) {
|
||||
adapterType = 'wireless';
|
||||
}
|
||||
if (netEnabled !== '') {
|
||||
const speed = parseInt(util.getValue(lines, 'speed', '=').trim(), 10) / 1000000;
|
||||
const speed = parseInt(util.getValue(lines, 'speed', ':').trim(), 10) / 1000000;
|
||||
nics.push({
|
||||
mac: util.getValue(lines, 'MACAddress', '=').toLowerCase(),
|
||||
dhcp: util.getValue(linesNicConfig, 'dhcpEnabled', '=').toLowerCase(),
|
||||
mac: util.getValue(lines, 'MACAddress', ':').toLowerCase(),
|
||||
dhcp: util.getValue(linesNicConfig, 'dhcpEnabled', ':').toLowerCase() === 'true',
|
||||
name: ifacename,
|
||||
iface,
|
||||
netEnabled: netEnabled === 'TRUE',
|
||||
speed: isNaN(speed) ? null : speed,
|
||||
operstate: util.getValue(lines, 'NetConnectionStatus', '=') === '2' ? 'up' : 'down',
|
||||
operstate: util.getValue(lines, 'NetConnectionStatus', ':') === '2' ? 'up' : 'down',
|
||||
type: adapterType
|
||||
});
|
||||
}
|
||||
@ -245,15 +245,24 @@ function parseLinesWindowsNics(sections, nconfigsections) {
|
||||
}
|
||||
|
||||
function getWindowsNics() {
|
||||
const cmd = util.getWmic() + ' nic get /value';
|
||||
const cmdnicconfig = util.getWmic() + ' nicconfig get dhcpEnabled /value';
|
||||
// const cmd = util.getWmic() + ' nic get /value';
|
||||
// const cmdnicconfig = util.getWmic() + ' nicconfig get dhcpEnabled /value';
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
let cmd = 'Get-WmiObject Win32_NetworkAdapter | fl *' + '; echo \'#-#-#-#\';';
|
||||
cmd += 'Get-WmiObject Win32_NetworkAdapterConfiguration | fl DHCPEnabled' + '';
|
||||
try {
|
||||
const nsections = execSync(cmd, util.execOptsWin).split(/\n\s*\n/);
|
||||
const nconfigsections = execSync(cmdnicconfig, util.execOptsWin).split(/\n\s*\n/);
|
||||
return (parseLinesWindowsNics(nsections, nconfigsections));
|
||||
util.powerShell(cmd).then(data => {
|
||||
data = data.split('#-#-#-#');
|
||||
const nsections = data[0].split(/\n\s*\n/);
|
||||
const nconfigsections = data[1].split(/\n\s*\n/);
|
||||
resolve(parseLinesWindowsNics(nsections, nconfigsections));
|
||||
});
|
||||
} catch (e) {
|
||||
return [];
|
||||
resolve([]);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getWindowsDNSsuffixes() {
|
||||
@ -743,7 +752,8 @@ function networkInterfaces(callback, rescan) {
|
||||
_networkInterfaces = result;
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
} else {
|
||||
}
|
||||
if (_linux) {
|
||||
if ((JSON.stringify(ifaces) === JSON.stringify(_ifaces)) && !rescan) {
|
||||
// no changes - just return object
|
||||
result = _networkInterfaces;
|
||||
@ -751,35 +761,9 @@ function networkInterfaces(callback, rescan) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
} else {
|
||||
_ifaces = Object.assign({}, ifaces);
|
||||
|
||||
if (_windows) {
|
||||
nics = getWindowsNics();
|
||||
nics.forEach(nic => {
|
||||
let found = false;
|
||||
Object.keys(ifaces).forEach(key => {
|
||||
if (!found) {
|
||||
ifaces[key].forEach(value => {
|
||||
if (Object.keys(value).indexOf('mac') >= 0) {
|
||||
found = value['mac'] === nic.mac;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (!found) {
|
||||
ifaces[nic.name] = [{ mac: nic.mac }];
|
||||
}
|
||||
});
|
||||
|
||||
nics8021xInfo = getWindowsWiredProfilesInformation();
|
||||
dnsSuffixes = getWindowsDNSsuffixes();
|
||||
}
|
||||
if (_linux) {
|
||||
_ifaces = JSON.parse(JSON.stringify(ifaces));
|
||||
_dhcpNics = getLinuxDHCPNics();
|
||||
}
|
||||
for (let dev in ifaces) {
|
||||
let iface = dev;
|
||||
let ip4 = '';
|
||||
let ip4subnet = '';
|
||||
let ip6 = '';
|
||||
@ -819,7 +803,6 @@ function networkInterfaces(callback, rescan) {
|
||||
mac = _mac[dev] || '';
|
||||
}
|
||||
});
|
||||
if (_linux) {
|
||||
let iface = dev.split(':')[0].trim().toLowerCase();
|
||||
const cmd = `echo -n "addr_assign_type: "; cat /sys/class/net/${iface}/addr_assign_type 2>/dev/null; echo;
|
||||
echo -n "address: "; cat /sys/class/net/${iface}/address 2>/dev/null; echo;
|
||||
@ -872,32 +855,7 @@ function networkInterfaces(callback, rescan) {
|
||||
operstate = util.getValue(lines, 'operstate');
|
||||
type = operstate === 'up' ? (util.getValue(lines, 'wireless').trim() ? 'wireless' : 'wired') : 'unknown';
|
||||
if (iface === 'lo' || iface.startsWith('bond')) { type = 'virtual'; }
|
||||
}
|
||||
if (_windows) {
|
||||
|
||||
|
||||
dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, dev);
|
||||
let foundFirst = false;
|
||||
nics.forEach(detail => {
|
||||
if (detail.mac === mac && !foundFirst) {
|
||||
iface = detail.iface || iface;
|
||||
ifaceName = detail.name;
|
||||
dhcp = detail.dhcp;
|
||||
operstate = detail.operstate;
|
||||
speed = detail.speed;
|
||||
type = detail.type;
|
||||
foundFirst = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('802.11n') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0 || ifaceName.toLowerCase().indexOf('wi-fi') >= 0 || ifaceName.toLowerCase().indexOf('wifi') >= 0) {
|
||||
type = 'wireless';
|
||||
}
|
||||
|
||||
const IEEE8021x = getWindowsIEEE8021x(type, dev, nics8021xInfo);
|
||||
ieee8021xAuth = IEEE8021x.protocol;
|
||||
ieee8021xState = IEEE8021x.state;
|
||||
}
|
||||
let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : false;
|
||||
if (dev.toLowerCase().indexOf('loopback') > -1 || ifaceName.toLowerCase().indexOf('loopback') > -1) {
|
||||
internal = true;
|
||||
@ -931,6 +889,134 @@ function networkInterfaces(callback, rescan) {
|
||||
resolve(result);
|
||||
}
|
||||
}
|
||||
if (_windows) {
|
||||
if ((JSON.stringify(ifaces) === JSON.stringify(_ifaces)) && !rescan) {
|
||||
// no changes - just return object
|
||||
result = _networkInterfaces;
|
||||
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
} else {
|
||||
_ifaces = JSON.parse(JSON.stringify(ifaces));
|
||||
|
||||
getWindowsNics().then(function (nics) {
|
||||
nics.forEach(nic => {
|
||||
let found = false;
|
||||
Object.keys(ifaces).forEach(key => {
|
||||
if (!found) {
|
||||
ifaces[key].forEach(value => {
|
||||
if (Object.keys(value).indexOf('mac') >= 0) {
|
||||
found = value['mac'] === nic.mac;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (!found) {
|
||||
ifaces[nic.name] = [{ mac: nic.mac }];
|
||||
}
|
||||
});
|
||||
nics8021xInfo = getWindowsWiredProfilesInformation();
|
||||
dnsSuffixes = getWindowsDNSsuffixes();
|
||||
for (let dev in ifaces) {
|
||||
let iface = dev;
|
||||
let ip4 = '';
|
||||
let ip4subnet = '';
|
||||
let ip6 = '';
|
||||
let ip6subnet = '';
|
||||
let mac = '';
|
||||
let duplex = '';
|
||||
let mtu = '';
|
||||
let speed = null;
|
||||
let carrierChanges = 0;
|
||||
let operstate = 'down';
|
||||
let dhcp = false;
|
||||
let dnsSuffix = '';
|
||||
let ieee8021xAuth = '';
|
||||
let ieee8021xState = '';
|
||||
let type = '';
|
||||
|
||||
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
||||
let ifaceName = dev;
|
||||
ifaces[dev].forEach(function (details) {
|
||||
if (details.family === 'IPv4') {
|
||||
ip4 = details.address;
|
||||
ip4subnet = details.netmask;
|
||||
}
|
||||
if (details.family === 'IPv6') {
|
||||
if (!ip6 || ip6.match(/^fe80::/i)) {
|
||||
ip6 = details.address;
|
||||
ip6subnet = details.netmask;
|
||||
}
|
||||
}
|
||||
mac = details.mac;
|
||||
// fallback due to https://github.com/nodejs/node/issues/13581 (node 8.1 - node 8.2)
|
||||
const nodeMainVersion = parseInt(process.versions.node.split('.'), 10);
|
||||
if (mac.indexOf('00:00:0') > -1 && (_linux || _darwin) && (!details.internal) && nodeMainVersion >= 8 && nodeMainVersion <= 11) {
|
||||
if (Object.keys(_mac).length === 0) {
|
||||
_mac = getMacAddresses();
|
||||
}
|
||||
mac = _mac[dev] || '';
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
dnsSuffix = getWindowsIfaceDNSsuffix(dnsSuffixes.ifaces, dev);
|
||||
let foundFirst = false;
|
||||
nics.forEach(detail => {
|
||||
if (detail.mac === mac && !foundFirst) {
|
||||
iface = detail.iface || iface;
|
||||
ifaceName = detail.name;
|
||||
dhcp = detail.dhcp;
|
||||
operstate = detail.operstate;
|
||||
speed = detail.speed;
|
||||
type = detail.type;
|
||||
foundFirst = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (dev.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('wlan') >= 0 || ifaceName.toLowerCase().indexOf('802.11n') >= 0 || ifaceName.toLowerCase().indexOf('wireless') >= 0 || ifaceName.toLowerCase().indexOf('wi-fi') >= 0 || ifaceName.toLowerCase().indexOf('wifi') >= 0) {
|
||||
type = 'wireless';
|
||||
}
|
||||
|
||||
const IEEE8021x = getWindowsIEEE8021x(type, dev, nics8021xInfo);
|
||||
ieee8021xAuth = IEEE8021x.protocol;
|
||||
ieee8021xState = IEEE8021x.state;
|
||||
let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : false;
|
||||
if (dev.toLowerCase().indexOf('loopback') > -1 || ifaceName.toLowerCase().indexOf('loopback') > -1) {
|
||||
internal = true;
|
||||
}
|
||||
const virtual = internal ? false : testVirtualNic(dev, ifaceName, mac);
|
||||
result.push({
|
||||
iface,
|
||||
ifaceName,
|
||||
ip4,
|
||||
ip4subnet,
|
||||
ip6,
|
||||
ip6subnet,
|
||||
mac,
|
||||
internal,
|
||||
virtual,
|
||||
operstate,
|
||||
type,
|
||||
duplex,
|
||||
mtu,
|
||||
speed,
|
||||
dhcp,
|
||||
dnsSuffix,
|
||||
ieee8021xAuth,
|
||||
ieee8021xState,
|
||||
carrierChanges,
|
||||
});
|
||||
}
|
||||
}
|
||||
_networkInterfaces = result;
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -1425,7 +1511,7 @@ function networkConnections(callback) {
|
||||
peeraddress.pop();
|
||||
peerip = peeraddress.join(':');
|
||||
}
|
||||
let pid = line[4];
|
||||
let pid = util.toInt(line[4]);
|
||||
let connstate = line[3];
|
||||
if (connstate === 'HERGESTELLT') { connstate = 'ESTABLISHED'; }
|
||||
if (connstate.startsWith('ABH')) { connstate = 'LISTEN'; }
|
||||
|
||||
@ -1111,12 +1111,10 @@ echo -n "hardware: "; cat /sys/class/dmi/id/product_uuid 2> /dev/null; echo;`;
|
||||
});
|
||||
}
|
||||
if (_freebsd || _openbsd || _netbsd) {
|
||||
const cmd = `echo -n "os: "; sysctl -n kern.hostid; echo;
|
||||
echo -n "hardware: "; sysctl -n kern.hostuuid; echo;`;
|
||||
exec(cmd, function (error, stdout) {
|
||||
exec('sysctl -i kern.hostid kern.hostuuid', function (error, stdout) {
|
||||
const lines = stdout.toString().split('\n');
|
||||
result.os = util.getValue(lines, 'os').toLowerCase();
|
||||
result.hardware = util.getValue(lines, 'hardware').toLowerCase();
|
||||
result.os = util.getValue(lines, 'kern.hostid', ':').toLowerCase();
|
||||
result.hardware = util.getValue(lines, 'kern.hostuuid', ':').toLowerCase();
|
||||
if (result.os.indexOf('unknown') >= 0) { result.os = ''; }
|
||||
if (result.hardware.indexOf('unknown') >= 0) { result.hardware = ''; }
|
||||
if (callback) {
|
||||
|
||||
@ -461,6 +461,7 @@ function bios(callback) {
|
||||
let datetime = util.getValue(lines, 'Release Date');
|
||||
result.releaseDate = util.parseDateTime(datetime).date;
|
||||
result.revision = util.getValue(lines, 'BIOS Revision');
|
||||
result.serial = util.getValue(lines, 'SerialNumber');
|
||||
let language = util.getValue(lines, 'Currently Installed Language').split('|')[0];
|
||||
if (language) {
|
||||
result.language = language;
|
||||
@ -538,6 +539,7 @@ function bios(callback) {
|
||||
result.releaseDate = result.releaseDate.substr(0, 4) + '-' + result.releaseDate.substr(4, 2) + '-' + result.releaseDate.substr(6, 2);
|
||||
}
|
||||
result.revision = util.getValue(lines, 'buildnumber', ':');
|
||||
result.serial = util.getValue(lines, 'serialnumber', ':');
|
||||
}
|
||||
|
||||
if (callback) { callback(result); }
|
||||
|
||||
21
lib/users.js
21
lib/users.js
@ -283,16 +283,21 @@ function users(callback) {
|
||||
}
|
||||
if (_windows) {
|
||||
try {
|
||||
const workload = [];
|
||||
// workload.push(util.powerShell('Get-CimInstance -ClassName Win32_Account | fl *'));
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_LogonSession | fl *'));
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_LoggedOnUser | fl *'));
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_Process -Filter "name=\'explorer.exe\'" | Select @{Name="domain";Expression={$_.GetOwner().Domain}}, @{Name="username";Expression={$_.GetOwner().User}} | fl'));
|
||||
Promise.all(
|
||||
workload
|
||||
).then(data => {
|
||||
// const workload = [];
|
||||
// // workload.push(util.powerShell('Get-CimInstance -ClassName Win32_Account | fl *'));
|
||||
// workload.push(util.powerShell('Get-WmiObject Win32_LogonSession | fl *'));
|
||||
// workload.push(util.powerShell('Get-WmiObject Win32_LoggedOnUser | fl *'));
|
||||
// workload.push(util.powerShell('Get-WmiObject Win32_Process -Filter "name=\'explorer.exe\'" | Select @{Name="domain";Expression={$_.GetOwner().Domain}}, @{Name="username";Expression={$_.GetOwner().User}} | fl'));
|
||||
// Promise.all(
|
||||
// workload
|
||||
// ).then(data => {
|
||||
let cmd = 'Get-WmiObject Win32_LogonSession | fl *' + '; echo \'#-#-#-#\';';
|
||||
cmd += 'Get-WmiObject Win32_LoggedOnUser | fl *' + '; echo \'#-#-#-#\';';
|
||||
cmd += 'Get-WmiObject Win32_Process -Filter "name=\'explorer.exe\'" | Select @{Name="domain";Expression={$_.GetOwner().Domain}}, @{Name="username";Expression={$_.GetOwner().User}} | fl';
|
||||
util.powerShell(cmd).then(data => {
|
||||
// controller + vram
|
||||
// let accounts = parseWinAccounts(data[0].split(/\n\s*\n/));
|
||||
data = data.split('#-#-#-#');
|
||||
let sessions = parseWinSessions(data[0].split(/\n\s*\n/));
|
||||
let loggedons = parseWinLoggedOn(data[1].split(/\n\s*\n/));
|
||||
let users = parseWinUsers(data[2].split(/\n\s*\n/));
|
||||
|
||||
@ -360,7 +360,7 @@ function powerShell(cmd) {
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
try {
|
||||
const child = spawn('powershell.exe', ['-NoLogo', '-InputFormat', 'Text', '-NoExit', '-ExecutionPolicy', 'Unrestricted', '-Command', '-'], {
|
||||
const child = spawn('powershell.exe', ['-NoLogo', '-NoProfile', '-InputFormat', 'Text', '-NoExit', '-ExecutionPolicy', 'Unrestricted', '-Command', '-'], { // added NoProfile
|
||||
stdio: 'pipe',
|
||||
windowsHide: true,
|
||||
maxBuffer: 1024 * 20000,
|
||||
@ -875,6 +875,7 @@ function decodePiCpuinfo(lines) {
|
||||
'0f': 'Internal use only',
|
||||
'10': 'CM3+',
|
||||
'11': '4B',
|
||||
'12': 'Zero 2 W',
|
||||
'13': '400',
|
||||
'14': 'CM4'
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user