get DHCP status in linux
This commit is contained in:
parent
40bdd6fc11
commit
73a2ad62b1
@ -317,6 +317,31 @@ function getDarwinNics() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getNicDHCPstatus(interfaceName) {
|
||||||
|
const cmd = `nmcli con sh "${interfaceName}" | grep ipv4.method`;
|
||||||
|
console.log(cmd);
|
||||||
|
try {
|
||||||
|
let dhcpStatus = "";
|
||||||
|
const lines = execSync(cmd, util.execOptsWin).toString().split('\n');
|
||||||
|
const nsections = splitSectionsNics(lines);
|
||||||
|
console.log(nsections);
|
||||||
|
switch (key) {
|
||||||
|
case "auto":
|
||||||
|
dhcpStatus = "true";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
dhcpStatus = "false";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return dhcpStatus;
|
||||||
|
} catch (e) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function testVirtualNic(iface, ifaceName, mac) {
|
function testVirtualNic(iface, ifaceName, mac) {
|
||||||
const virtualMacs = ['00:00:00:00:00:00', '00:03:FF', '00:05:69', '00:0C:29', '00:0F:4B', '00:0F:4B', '00:13:07', '00:13:BE', '00:15:5d', '00:16:3E', '00:1C:42', '00:21:F6', '00:21:F6', '00:24:0B', '00:24:0B', '00:50:56', '00:A0:B1', '00:E0:C8', '08:00:27', '0A:00:27', '18:92:2C', '16:DF:49', '3C:F3:92', '54:52:00', 'FC:15:97'];
|
const virtualMacs = ['00:00:00:00:00:00', '00:03:FF', '00:05:69', '00:0C:29', '00:0F:4B', '00:0F:4B', '00:13:07', '00:13:BE', '00:15:5d', '00:16:3E', '00:1C:42', '00:21:F6', '00:21:F6', '00:24:0B', '00:24:0B', '00:50:56', '00:A0:B1', '00:E0:C8', '08:00:27', '0A:00:27', '18:92:2C', '16:DF:49', '3C:F3:92', '54:52:00', 'FC:15:97'];
|
||||||
if (mac) {
|
if (mac) {
|
||||||
@ -342,11 +367,11 @@ function networkInterfaces(callback) {
|
|||||||
// seperate handling in OSX
|
// seperate handling in OSX
|
||||||
if (_darwin || _freebsd || _openbsd || _netbsd) {
|
if (_darwin || _freebsd || _openbsd || _netbsd) {
|
||||||
nics = getDarwinNics();
|
nics = getDarwinNics();
|
||||||
// console.log(nics);
|
|
||||||
// console.log('-------');
|
|
||||||
// console.log(ifaces);
|
|
||||||
nics.forEach(nic => {
|
nics.forEach(nic => {
|
||||||
|
|
||||||
|
dhcpStatus = getNicDHCPstatus(nic.iface);
|
||||||
|
|
||||||
result.push({
|
result.push({
|
||||||
iface: nic.iface,
|
iface: nic.iface,
|
||||||
ifaceName: nic.iface,
|
ifaceName: nic.iface,
|
||||||
@ -358,6 +383,7 @@ function networkInterfaces(callback) {
|
|||||||
operstate: nic.operstate,
|
operstate: nic.operstate,
|
||||||
type: nic.type,
|
type: nic.type,
|
||||||
duplex: nic.duplex,
|
duplex: nic.duplex,
|
||||||
|
dhcpStatus: dhcpStatus,
|
||||||
mtu: nic.mtu,
|
mtu: nic.mtu,
|
||||||
speed: nic.speed,
|
speed: nic.speed,
|
||||||
carrierChanges: 0
|
carrierChanges: 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user