networkInterfaces() type detection improved (win)

This commit is contained in:
Sebastian Hildebrandt
2021-01-27 22:11:43 +01:00
parent aa3f1a3815
commit 22d35b2dee
5 changed files with 21 additions and 10 deletions
+7 -3
View File
@@ -219,17 +219,21 @@ 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, '(');
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;
nics.push({
mac: util.getValue(lines, 'MACAddress', '=').toLowerCase(),
dhcp: util.getValue(linesNicConfig, 'dhcpEnabled', '=').toLowerCase(),
name: util.getValue(lines, 'Name', '=').replace(/\]/g, ')').replace(/\[/g, '('),
name: ifacename,
netEnabled: netEnabled === 'TRUE',
speed: isNaN(speed) ? null : speed,
operstate: util.getValue(lines, 'NetConnectionStatus', '=') === '2' ? 'up' : 'down',
type: util.getValue(lines, 'AdapterTypeID', '=') === '9' ? 'wireless' : 'wired'
type: adapterType
});
}
}