added support for 'ip' instead of 'ifconfig'
This commit is contained in:
parent
c44e40859f
commit
9d13697be1
@ -100,6 +100,7 @@ Other changes
|
||||
|
||||
| Version | Date | Comment |
|
||||
| -------------- | -------------- | -------- |
|
||||
| 3.37.5 | 2018-03-12 | added support for `ip` instead of `ifconfig` |
|
||||
| 3.37.4 | 2018-02-22 | bugfix windows `processes()`, `disklayout()` |
|
||||
| 3.37.3 | 2018-02-19 | added windows exec `windowsHide` option |
|
||||
| 3.37.2 | 2018-02-15 | fixed bug `battery().percent` for macOS |
|
||||
|
||||
@ -560,6 +560,7 @@ Written by Sebastian Hildebrandt [sebhildebrandt](https://github.com/sebhildebra
|
||||
- dragonjet [dragonjet](https://github.com/dragonjet)
|
||||
- Adam Reis [adamreisnz](https://github.com/adamreisnz)
|
||||
- Jimi M [ItsJimi](https://github.com/ItsJimi)
|
||||
- Git² [GitSquared](https://github.com/GitSquared)
|
||||
|
||||
OSX Temperature: credits here are going to:
|
||||
|
||||
|
||||
@ -144,7 +144,7 @@ function getStaticData(callback) {
|
||||
data.bios = res[1];
|
||||
data.baseboard = res[2];
|
||||
data.os = res[3];
|
||||
data.versions =res[4];
|
||||
data.versions = res[4];
|
||||
data.cpu = res[5];
|
||||
data.cpu.flags = res[6];
|
||||
data.graphics = res[7];
|
||||
|
||||
@ -33,6 +33,7 @@ const opts = {
|
||||
let _network = {};
|
||||
let _default_iface;
|
||||
let _mac = {};
|
||||
let isIpAvailable;
|
||||
|
||||
function getDefaultNetworkInterface() {
|
||||
|
||||
@ -78,13 +79,30 @@ function getMacAddresses() {
|
||||
let mac = '';
|
||||
let result = {};
|
||||
if (_linux || _freebsd || _openbsd) {
|
||||
const cmd = 'export LC_ALL=C; /sbin/ifconfig; unset LC_ALL';
|
||||
if (typeof isIpAvailable === 'undefined') {
|
||||
if (fs.existsSync('/sbin/ip')) {
|
||||
isIpAvailable = true;
|
||||
} else {
|
||||
isIpAvailable = false;
|
||||
}
|
||||
}
|
||||
const cmd = 'export LC_ALL=C; /sbin/' + ((isIpAvailable) ? 'ip link show up' : 'ifconfig') + '; unset LC_ALL';
|
||||
let res = execSync(cmd);
|
||||
const lines = res.toString().split('\n');
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (lines[i] && lines[i][0] !== ' ') {
|
||||
iface = lines[i].split(' ')[0];
|
||||
mac = lines[i].split('HWaddr ')[1];
|
||||
if (isIpAvailable) {
|
||||
let nextline = lines[i+1].trim().split(' ');
|
||||
if (nextline[0] === 'link/ether') {
|
||||
iface = lines[i].split(' ')[1];
|
||||
iface = iface.slice(0, iface.length - 1);
|
||||
mac = nextline[1];
|
||||
}
|
||||
} else {
|
||||
iface = lines[i].split(' ')[0];
|
||||
mac = lines[i].split('HWaddr ')[1];
|
||||
}
|
||||
|
||||
if (iface && mac) {
|
||||
result[iface] = mac.trim();
|
||||
iface = '';
|
||||
@ -92,7 +110,6 @@ function getMacAddresses() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (_darwin) {
|
||||
const cmd = '/sbin/ifconfig';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user