Get DNS Suffix in linux
This commit is contained in:
parent
03eae68972
commit
18b6e8b87d
@ -311,7 +311,7 @@ function getDarwinNics() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getInterfaceConnectionName(interfaceName) {
|
function getLinuxIfaceConnectionName(interfaceName) {
|
||||||
const cmd = `nmcli device status | grep ${interfaceName}`;
|
const cmd = `nmcli device status | grep ${interfaceName}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -325,7 +325,7 @@ function getInterfaceConnectionName(interfaceName) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInterfaceDHCPstatus(connectionName) {
|
function getLinuxIfaceDHCPstatus(connectionName) {
|
||||||
if(connectionName) {
|
if(connectionName) {
|
||||||
const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.method;`;
|
const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.method;`;
|
||||||
try {
|
try {
|
||||||
@ -351,14 +351,14 @@ function getInterfaceDHCPstatus(connectionName) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInterfaceDNSsuffix(connectionName) {
|
function getLinuxIfaceDNSsuffix(connectionName) {
|
||||||
if(connectionName) {
|
if(connectionName) {
|
||||||
const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.dns-search;`;
|
const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.dns-search;`;
|
||||||
try {
|
try {
|
||||||
const result = execSync(cmd).toString();
|
const result = execSync(cmd).toString();
|
||||||
const resultFormat = result.replace(/\s+/g,' ').trim();
|
const resultFormat = result.replace(/\s+/g,' ').trim();
|
||||||
const dnsSuffix = resultFormat.split(" ").slice(1).toString();
|
const dnsSuffix = resultFormat.split(" ").slice(1).toString();
|
||||||
return dnsSuffix;
|
return dnsSuffix == '--' ? '': dnsSuffix;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return 'Unknow';
|
return 'Unknow';
|
||||||
}
|
}
|
||||||
@ -489,9 +489,9 @@ function networkInterfaces(callback) {
|
|||||||
let lines = [];
|
let lines = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const connectionName = getInterfaceConnectionName(iface);
|
const connectionName = getLinuxIfaceConnectionName(iface);
|
||||||
dhcp = getInterfaceDHCPstatus(connectionName);
|
dhcp = getLinuxIfaceDHCPstatus(connectionName);
|
||||||
dnsSuffix = getInterfaceDNSsuffix(connectionName);
|
dnsSuffix = getLinuxIfaceDNSsuffix(connectionName);
|
||||||
lines = execSync(cmd).toString().split('\n');
|
lines = execSync(cmd).toString().split('\n');
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user