Skip to content

Commit e8732d4

Browse files
networkConnections: improved parsing (macOS)
1 parent e91f61d commit e8732d4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/network.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,20 +1534,19 @@ function networkConnections(callback) {
15341534
});
15351535
}
15361536
if (_darwin) {
1537-
let cmd = 'netstat -natvln | grep "tcp4\\|tcp6\\|udp4\\|udp6\\|Recv-Q"';
1537+
let cmd = 'netstat -natvln | grep "tcp4\\|tcp6\\|udp4\\|udp6"';
15381538
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';
15391539
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
15401540
if (!error) {
15411541
exec('ps -axo pid,command', { maxBuffer: 1024 * 20000 }, function (err2, stdout2) {
15421542
let processes = stdout2.toString().split('\n');
15431543
processes = processes.map((line => { return line.trim().replace(/ +/g, ' '); }));
15441544
let lines = stdout.toString().split('\n');
1545-
const header = lines[0];
1546-
const hasTransferred = header.indexOf('rxbytes') > -1;
1547-
lines.shift();
1545+
15481546

15491547
lines.forEach(function (line) {
15501548
line = line.replace(/ +/g, ' ').split(' ');
1549+
const hasTransferred = line.length >= 19;
15511550
if (line.length >= 8) {
15521551
let localip = line[3];
15531552
let localport = '';

0 commit comments

Comments
 (0)