minor fixes
This commit is contained in:
parent
e24054f645
commit
fe8f5936cb
@ -212,33 +212,42 @@ exports.networkInterfaceDefault = networkInterfaceDefault;
|
|||||||
function parseLinesWindowsNics(sections, nconfigsections) {
|
function parseLinesWindowsNics(sections, nconfigsections) {
|
||||||
let nics = [];
|
let nics = [];
|
||||||
for (let i in sections) {
|
for (let i in sections) {
|
||||||
if ({}.hasOwnProperty.call(sections, i)) {
|
try {
|
||||||
|
if ({}.hasOwnProperty.call(sections, i)) {
|
||||||
|
|
||||||
if (sections[i].trim() !== '') {
|
if (sections[i].trim() !== '') {
|
||||||
|
|
||||||
let lines = sections[i].trim().split('\r\n');
|
let lines = sections[i].trim().split('\r\n');
|
||||||
let linesNicConfig = nconfigsections && nconfigsections[i] ? nconfigsections[i].trim().split('\r\n') : [];
|
let linesNicConfig = null;
|
||||||
let netEnabled = util.getValue(lines, 'NetEnabled', ':');
|
try {
|
||||||
let adapterType = util.getValue(lines, 'AdapterTypeID', ':') === '9' ? 'wireless' : 'wired';
|
linesNicConfig = nconfigsections && nconfigsections[i] ? nconfigsections[i].trim().split('\r\n') : [];
|
||||||
let ifacename = util.getValue(lines, 'Name', ':').replace(/\]/g, ')').replace(/\[/g, '(');
|
} catch (e) {
|
||||||
let iface = util.getValue(lines, 'NetConnectionID', ':').replace(/\]/g, ')').replace(/\[/g, '(');
|
util.noop();
|
||||||
if (ifacename.toLowerCase().indexOf('wi-fi') >= 0 || ifacename.toLowerCase().indexOf('wireless') >= 0) {
|
}
|
||||||
adapterType = 'wireless';
|
let netEnabled = util.getValue(lines, 'NetEnabled', ':');
|
||||||
}
|
let adapterType = util.getValue(lines, 'AdapterTypeID', ':') === '9' ? 'wireless' : 'wired';
|
||||||
if (netEnabled !== '') {
|
let ifacename = util.getValue(lines, 'Name', ':').replace(/\]/g, ')').replace(/\[/g, '(');
|
||||||
const speed = parseInt(util.getValue(lines, 'speed', ':').trim(), 10) / 1000000;
|
let iface = util.getValue(lines, 'NetConnectionID', ':').replace(/\]/g, ')').replace(/\[/g, '(');
|
||||||
nics.push({
|
if (ifacename.toLowerCase().indexOf('wi-fi') >= 0 || ifacename.toLowerCase().indexOf('wireless') >= 0) {
|
||||||
mac: util.getValue(lines, 'MACAddress', ':').toLowerCase(),
|
adapterType = 'wireless';
|
||||||
dhcp: util.getValue(linesNicConfig, 'dhcpEnabled', ':').toLowerCase() === 'true',
|
}
|
||||||
name: ifacename,
|
if (netEnabled !== '') {
|
||||||
iface,
|
const speed = parseInt(util.getValue(lines, 'speed', ':').trim(), 10) / 1000000;
|
||||||
netEnabled: netEnabled === 'TRUE',
|
nics.push({
|
||||||
speed: isNaN(speed) ? null : speed,
|
mac: util.getValue(lines, 'MACAddress', ':').toLowerCase(),
|
||||||
operstate: util.getValue(lines, 'NetConnectionStatus', ':') === '2' ? 'up' : 'down',
|
dhcp: util.getValue(linesNicConfig, 'dhcpEnabled', ':').toLowerCase() === 'true',
|
||||||
type: adapterType
|
name: ifacename,
|
||||||
});
|
iface,
|
||||||
|
netEnabled: netEnabled === 'TRUE',
|
||||||
|
speed: isNaN(speed) ? null : speed,
|
||||||
|
operstate: util.getValue(lines, 'NetConnectionStatus', ':') === '2' ? 'up' : 'down',
|
||||||
|
type: adapterType
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
util.noop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nics;
|
return nics;
|
||||||
|
|||||||
@ -579,7 +579,7 @@ function getCodepage() {
|
|||||||
if (_linux || _darwin || _freebsd || _openbsd || _netbsd) {
|
if (_linux || _darwin || _freebsd || _openbsd || _netbsd) {
|
||||||
if (!codepage) {
|
if (!codepage) {
|
||||||
try {
|
try {
|
||||||
const stdout = execSync('echo $LANG', util.execOptsLinux);
|
const stdout = execSync('echo $LANG', execOptsLinux);
|
||||||
const lines = stdout.toString().split('\r\n');
|
const lines = stdout.toString().split('\r\n');
|
||||||
const parts = lines[0].split('.');
|
const parts = lines[0].split('.');
|
||||||
codepage = parts.length > 1 ? parts[1].trim() : '';
|
codepage = parts.length > 1 ? parts[1].trim() : '';
|
||||||
@ -1156,7 +1156,7 @@ function linuxVersion() {
|
|||||||
let result = '';
|
let result = '';
|
||||||
if (_linux) {
|
if (_linux) {
|
||||||
try {
|
try {
|
||||||
result = execSync('uname -v', util.execOptsLinux).toString();
|
result = execSync('uname -v', execOptsLinux).toString();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
result = '';
|
result = '';
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user