network mac adresses: ip support fix
This commit is contained in:
parent
affa4e39ce
commit
1fbdeecef8
@ -100,6 +100,7 @@ Other changes
|
||||
|
||||
| Version | Date | Comment |
|
||||
| -------------- | -------------- | -------- |
|
||||
| 3.50.2 | 2018-11-23 | network mac adresses: ip support fix |
|
||||
| 3.50.1 | 2018-11-23 | `services()` added possibility to specify ALL services "*" for win |
|
||||
| 3.50.0 | 2018-11-23 | `services()` added possibility to specify ALL services "*" for linux |
|
||||
| 3.49.4 | 2018-11-21 | `battery()` timeremaining optimization (linux) thanks to Jorai Rijsdijk |
|
||||
|
||||
@ -378,7 +378,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
|
||||
| | pid | X | X | X | | | PID |
|
||||
| | cpu | X | X | X | | | process % CPU |
|
||||
| | mem | X | X | X | | | process % MEM |
|
||||
| si.services('mysql, apache2', cb) | [{...}] | X | X | X | X | | pass comma separated string of services<br>pass "*" for ALL services (linux only) |
|
||||
| si.services('mysql, apache2', cb) | [{...}] | X | X | X | X | | pass comma separated string of services<br>pass "*" for ALL services (linux/win only) |
|
||||
| | [0].name | X | X | X | X | | name of service |
|
||||
| | [0].running | X | X | X | X | | true / false |
|
||||
| | [0].startmode | | | | X | | manual, automatic, ... |
|
||||
|
||||
@ -30,7 +30,7 @@ const _sunos = (_platform === 'sunos');
|
||||
let _network = {};
|
||||
let _default_iface;
|
||||
let _mac = {};
|
||||
let isIpAvailable;
|
||||
let pathToIp;
|
||||
|
||||
function getDefaultNetworkInterface() {
|
||||
|
||||
@ -72,19 +72,24 @@ function getMacAddresses() {
|
||||
let mac = '';
|
||||
let result = {};
|
||||
if (_linux || _freebsd || _openbsd) {
|
||||
if (typeof isIpAvailable === 'undefined') {
|
||||
if (fs.existsSync('/sbin/ip')) {
|
||||
isIpAvailable = true;
|
||||
} else {
|
||||
isIpAvailable = false;
|
||||
if (typeof pathToIp === 'undefined') {
|
||||
try {
|
||||
const lines = execSync('which ip').toString().split('\n');
|
||||
if (lines.length && lines[0].indexOf(':') === -1 && lines[0].indexOf('/') === 0) {
|
||||
pathToIp = lines[0];
|
||||
} else {
|
||||
pathToIp = '';
|
||||
}
|
||||
} catch (e) {
|
||||
pathToIp = '';
|
||||
}
|
||||
}
|
||||
const cmd = 'export LC_ALL=C; /sbin/' + ((isIpAvailable) ? 'ip link show up' : 'ifconfig') + '; unset LC_ALL';
|
||||
const cmd = 'export LC_ALL=C; ' + ((pathToIp) ? pathToIp + ' link show up' : '/sbin/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] !== ' ') {
|
||||
if (isIpAvailable) {
|
||||
if (pathToIp) {
|
||||
let nextline = lines[i + 1].trim().split(' ');
|
||||
if (nextline[0] === 'link/ether') {
|
||||
iface = lines[i].split(' ')[1];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user