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}`;
|
||||
|
||||
try {
|
||||
@ -325,7 +325,7 @@ function getInterfaceConnectionName(interfaceName) {
|
||||
}
|
||||
}
|
||||
|
||||
function getInterfaceDHCPstatus(connectionName) {
|
||||
function getLinuxIfaceDHCPstatus(connectionName) {
|
||||
if(connectionName) {
|
||||
const cmd = `nmcli connection show "${connectionName}" \| grep ipv4.method;`;
|
||||
try {
|
||||
@ -351,14 +351,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';
|
||||
}
|
||||
@ -489,9 +489,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');
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user