This commit is contained in:
ricardopolo 2019-11-01 11:30:30 -05:00
commit 3ef962a830

View File

@ -377,7 +377,7 @@ function getDarwinNics() {
}
function getInterfaceConnectionName(interfaceName) {
function getLinuxIfaceConnectionName(interfaceName) {
const cmd = `nmcli device status | grep ${interfaceName}`;
try {
@ -391,7 +391,7 @@ function getInterfaceConnectionName(interfaceName) {
}
}
function getInterfaceDHCPstatus(connectionName) {
function getLinuxIfaceDHCPstatus(connectionName) {
if(connectionName) {
const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.method;`;
try {
@ -417,16 +417,14 @@ function getInterfaceDHCPstatus(connectionName) {
}
}
function getInterfaceDNSsuffix(connectionName) {
function getLinuxIfaceDNSsuffix(connectionName) {
if(connectionName) {
const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.dns-search;`;
try {
const result = execSync(cmd).toString();
const resultFormat = result.replace(/\s+/g,' ').trim();
const dnsSuffix = resultFormat.split(" ").slice(1).toString();
return dnsSuffix;
return dnsSuffix == '--' ? '': dnsSuffix;
} catch (e) {
return 'Unknow';
}
@ -559,9 +557,9 @@ function networkInterfaces(callback) {
let lines = [];
try {
const connectionName = getInterfaceConnectionName(iface);
dhcp = getInterfaceDHCPstatus(connectionName);
dnsSuffix = getInterfaceDNSsuffix(connectionName);
const connectionName = getLinuxIfaceConnectionName(iface);
dhcp = getLinuxIfaceDHCPstatus(connectionName);
dnsSuffix = getLinuxIfaceDNSsuffix(connectionName);
lines = execSync(cmd).toString().split('\n');