networkConnections: improved parsing (macOS)
This commit is contained in:
parent
e91f61dd17
commit
e8732d42b9
@ -1534,7 +1534,7 @@ function networkConnections(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_darwin) {
|
if (_darwin) {
|
||||||
let cmd = 'netstat -natvln | grep "tcp4\\|tcp6\\|udp4\\|udp6\\|Recv-Q"';
|
let cmd = 'netstat -natvln | grep "tcp4\\|tcp6\\|udp4\\|udp6"';
|
||||||
const states = 'ESTABLISHED|SYN_SENT|SYN_RECV|FIN_WAIT1|FIN_WAIT_1|FIN_WAIT2|FIN_WAIT_2|TIME_WAIT|CLOSE|CLOSE_WAIT|LAST_ACK|LISTEN|CLOSING|UNKNOWN';
|
const states = 'ESTABLISHED|SYN_SENT|SYN_RECV|FIN_WAIT1|FIN_WAIT_1|FIN_WAIT2|FIN_WAIT_2|TIME_WAIT|CLOSE|CLOSE_WAIT|LAST_ACK|LISTEN|CLOSING|UNKNOWN';
|
||||||
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
|
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
@ -1542,12 +1542,11 @@ function networkConnections(callback) {
|
|||||||
let processes = stdout2.toString().split('\n');
|
let processes = stdout2.toString().split('\n');
|
||||||
processes = processes.map((line => { return line.trim().replace(/ +/g, ' '); }));
|
processes = processes.map((line => { return line.trim().replace(/ +/g, ' '); }));
|
||||||
let lines = stdout.toString().split('\n');
|
let lines = stdout.toString().split('\n');
|
||||||
const header = lines[0];
|
|
||||||
const hasTransferred = header.indexOf('rxbytes') > -1;
|
|
||||||
lines.shift();
|
|
||||||
|
|
||||||
lines.forEach(function (line) {
|
lines.forEach(function (line) {
|
||||||
line = line.replace(/ +/g, ' ').split(' ');
|
line = line.replace(/ +/g, ' ').split(' ');
|
||||||
|
const hasTransferred = line.length >= 19;
|
||||||
if (line.length >= 8) {
|
if (line.length >= 8) {
|
||||||
let localip = line[3];
|
let localip = line[3];
|
||||||
let localport = '';
|
let localport = '';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user