networkInterfaces() added DHCP status mac OS
This commit is contained in:
parent
4dccb59326
commit
b0308d4efb
@ -486,7 +486,7 @@ function getLinuxIfaceConnectionName(interfaceName) {
|
||||
}
|
||||
}
|
||||
|
||||
function getLinuxDHCPnNics() {
|
||||
function getLinuxDHCPNics() {
|
||||
// alternate methods getting interfaces using DHCP
|
||||
let cmd = 'ip a';
|
||||
let result = [];
|
||||
@ -563,6 +563,20 @@ function getLinuxIfaceDHCPstatus(iface, connectionName, DHCPNics) {
|
||||
}
|
||||
}
|
||||
|
||||
function getDarwinIfaceDHCPstatus(iface) {
|
||||
let result = false;
|
||||
const cmd = `ipconfig getpacket "${iface}" 2>/dev/null \| grep lease_time;`;
|
||||
try {
|
||||
const lines = execSync(cmd).toString().split('\n');
|
||||
if (lines.length && lines[0].startsWith('lease_time')) {
|
||||
result = true;
|
||||
}
|
||||
} catch (e) {
|
||||
util.noop();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function getLinuxIfaceDNSsuffix(connectionName) {
|
||||
if (connectionName) {
|
||||
const cmd = `nmcli connection show "${connectionName}" 2>/dev/null \| grep ipv4.dns-search;`;
|
||||
@ -651,7 +665,7 @@ function networkInterfaces(callback) {
|
||||
duplex: nic.duplex,
|
||||
mtu: nic.mtu,
|
||||
speed: nic.speed,
|
||||
dhcp: false,
|
||||
dhcp: getDarwinIfaceDHCPstatus(nic.iface),
|
||||
dnsSuffix: '',
|
||||
ieee8021xAuth: '',
|
||||
ieee8021xState: '',
|
||||
@ -675,7 +689,7 @@ function networkInterfaces(callback) {
|
||||
dnsSuffixes = getWindowsDNSsuffixes();
|
||||
}
|
||||
if (_linux) {
|
||||
_dhcpNics = getLinuxDHCPnNics();
|
||||
_dhcpNics = getLinuxDHCPNics();
|
||||
}
|
||||
for (let dev in ifaces) {
|
||||
let ip4 = '';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user