merged pull request networkInterfaces(), renamed properties, osInfo() macos added catalina detection

This commit is contained in:
Sebastian Hildebrandt 2020-01-02 22:06:15 +01:00
parent 0feb6469b8
commit 6e98139272
3 changed files with 115 additions and 106 deletions

4
lib/index.d.ts vendored
View File

@ -318,6 +318,10 @@ export namespace Systeminformation {
duplex: string;
mtu: number;
speed: number;
dhcp: boolean;
dnsSuffix: string;
ieee8021xAuth: string;
ieee8021xState: string;
carrier_changes: number;
}

View File

@ -266,7 +266,7 @@ function getWindowsDNSsuffixes() {
return dnsSuffixes;
} catch (error) {
console.log('An error occurred trying to bring the Connection-specific DNS suffix', error.message);
// console.log('An error occurred trying to bring the Connection-specific DNS suffix', error.message);
return {
primaryDNS: '',
exitCode: 0,
@ -290,7 +290,7 @@ function getWindowsIfaceDNSsuffix(ifaces, ifacename) {
if (!dnsSuffix) dnsSuffix = '';
return dnsSuffix;
} catch (error) {
console.log('Error getting Connection-specific DNS suffix: ', error.message);
// console.log('Error getting Connection-specific DNS suffix: ', error.message);
return 'Unknown';
}
}
@ -534,7 +534,7 @@ function getLinuxIfaceDNSsuffix(connectionName) {
}
}
function getLinuxIfaceAuth8021x(connectionName) {
function getLinuxIfaceIEEE8021xAuth(connectionName) {
if (connectionName) {
const cmd = `nmcli connection show "${connectionName}" \| grep 802-1x.eap;`;
try {
@ -552,7 +552,7 @@ function getLinuxIfaceAuth8021x(connectionName) {
}
}
function getLinuxIfaceState8021x(authenticationProtocol) {
function getLinuxIfaceIEEE8021xState(authenticationProtocol) {
if (authenticationProtocol) {
if (authenticationProtocol == 'Not defined') {
return 'Disabled';
@ -606,6 +606,10 @@ function networkInterfaces(callback) {
duplex: nic.duplex,
mtu: nic.mtu,
speed: nic.speed,
dhcp: false,
dnsSuffix: '',
ieee8021xAuth: '',
ieee8021xState: '',
carrierChanges: 0
});
});
@ -636,8 +640,8 @@ function networkInterfaces(callback) {
let operstate = 'down';
let dhcp = false;
let dnsSuffix = '';
let auth8021x = '';
let state8021x = '';
let ieee8021xAuth = '';
let ieee8021xState = '';
let type = '';
if (ifaces.hasOwnProperty(dev)) {
@ -693,8 +697,8 @@ function networkInterfaces(callback) {
const connectionName = getLinuxIfaceConnectionName(iface);
dhcp = getLinuxIfaceDHCPstatus(connectionName);
dnsSuffix = getLinuxIfaceDNSsuffix(connectionName);
auth8021x = getLinuxIfaceAuth8021x(connectionName);
state8021x = getLinuxIfaceState8021x(auth8021x);
ieee8021xAuth = getLinuxIfaceIEEE8021xAuth(connectionName);
ieee8021xState = getLinuxIfaceIEEE8021xState(ieee8021xAuth);
lines = execSync(cmd).toString().split('\n');
@ -735,8 +739,8 @@ function networkInterfaces(callback) {
}
const IEEE8021x = getWindowsIEEE8021x(type, dev, nics8021xInfo);
auth8021x = IEEE8021x.protocol;
state8021x = IEEE8021x.state;
ieee8021xAuth = IEEE8021x.protocol;
ieee8021xState = IEEE8021x.state;
}
let internal = (ifaces[dev] && ifaces[dev][0]) ? ifaces[dev][0].internal : null;
const virtual = internal ? false : testVirtualNic(dev, ifaceName, mac);
@ -755,8 +759,8 @@ function networkInterfaces(callback) {
speed,
dhcp,
dnsSuffix,
auth8021x,
state8021x,
ieee8021xAuth,
ieee8021xState,
carrierChanges,
});
}

View File

@ -264,6 +264,7 @@ function osInfo(callback) {
result.codename = (result.release.indexOf('10.12') > -1 ? 'macOS Sierra' : result.codename);
result.codename = (result.release.indexOf('10.13') > -1 ? 'macOS High Sierra' : result.codename);
result.codename = (result.release.indexOf('10.14') > -1 ? 'macOS Mojave' : result.codename);
result.codename = (result.release.indexOf('10.15') > -1 ? 'macOS Catalina' : result.codename);
result.codepage = util.getCodepage();
if (callback) {