network mac adresses: ip support fix
This commit is contained in:
parent
affa4e39ce
commit
1fbdeecef8
@ -100,6 +100,7 @@ Other changes
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| 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.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.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 |
|
| 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 |
|
| | pid | X | X | X | | | PID |
|
||||||
| | cpu | X | X | X | | | process % CPU |
|
| | cpu | X | X | X | | | process % CPU |
|
||||||
| | mem | X | X | X | | | process % MEM |
|
| | 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].name | X | X | X | X | | name of service |
|
||||||
| | [0].running | X | X | X | X | | true / false |
|
| | [0].running | X | X | X | X | | true / false |
|
||||||
| | [0].startmode | | | | X | | manual, automatic, ... |
|
| | [0].startmode | | | | X | | manual, automatic, ... |
|
||||||
|
|||||||
@ -30,7 +30,7 @@ const _sunos = (_platform === 'sunos');
|
|||||||
let _network = {};
|
let _network = {};
|
||||||
let _default_iface;
|
let _default_iface;
|
||||||
let _mac = {};
|
let _mac = {};
|
||||||
let isIpAvailable;
|
let pathToIp;
|
||||||
|
|
||||||
function getDefaultNetworkInterface() {
|
function getDefaultNetworkInterface() {
|
||||||
|
|
||||||
@ -72,19 +72,24 @@ function getMacAddresses() {
|
|||||||
let mac = '';
|
let mac = '';
|
||||||
let result = {};
|
let result = {};
|
||||||
if (_linux || _freebsd || _openbsd) {
|
if (_linux || _freebsd || _openbsd) {
|
||||||
if (typeof isIpAvailable === 'undefined') {
|
if (typeof pathToIp === 'undefined') {
|
||||||
if (fs.existsSync('/sbin/ip')) {
|
try {
|
||||||
isIpAvailable = true;
|
const lines = execSync('which ip').toString().split('\n');
|
||||||
|
if (lines.length && lines[0].indexOf(':') === -1 && lines[0].indexOf('/') === 0) {
|
||||||
|
pathToIp = lines[0];
|
||||||
} else {
|
} else {
|
||||||
isIpAvailable = false;
|
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);
|
let res = execSync(cmd);
|
||||||
const lines = res.toString().split('\n');
|
const lines = res.toString().split('\n');
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
if (lines[i] && lines[i][0] !== ' ') {
|
if (lines[i] && lines[i][0] !== ' ') {
|
||||||
if (isIpAvailable) {
|
if (pathToIp) {
|
||||||
let nextline = lines[i + 1].trim().split(' ');
|
let nextline = lines[i + 1].trim().split(' ');
|
||||||
if (nextline[0] === 'link/ether') {
|
if (nextline[0] === 'link/ether') {
|
||||||
iface = lines[i].split(' ')[1];
|
iface = lines[i].split(' ')[1];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user