networkConnections() refactored PID parsing (macOS)
This commit is contained in:
+6
-5
@@ -1417,9 +1417,10 @@ function getProcessName(processes, pid) {
|
||||
}
|
||||
});
|
||||
cmd = cmd.split(' -')[0];
|
||||
// return cmd;
|
||||
const cmdParts = cmd.split('/');
|
||||
return cmdParts[cmdParts.length - 1];
|
||||
cmd = cmd.split(' /')[0];
|
||||
return cmd;
|
||||
// const cmdParts = cmd.split('/');
|
||||
// return cmdParts[cmdParts.length - 1];
|
||||
}
|
||||
|
||||
function networkConnections(callback) {
|
||||
@@ -1546,7 +1547,7 @@ function networkConnections(callback) {
|
||||
|
||||
lines.forEach(function (line) {
|
||||
line = line.replace(/ +/g, ' ').split(' ');
|
||||
const hasTransferred = line.length >= 19;
|
||||
const hasTransferred = line.length >= 17;
|
||||
if (line.length >= 8) {
|
||||
let localip = line[3];
|
||||
let localport = '';
|
||||
@@ -1566,7 +1567,7 @@ function networkConnections(callback) {
|
||||
}
|
||||
const hasState = states.indexOf(line[5]) >= 0;
|
||||
let connstate = hasState ? line[5] : 'UNKNOWN';
|
||||
let pid = parseInt(line[8 + (hasState ? 0 : -1) + (hasTransferred ? 2 : 0)], 10);
|
||||
let pid = parseInt(line[6 + (hasState ? 0 : -1) + (hasTransferred ? 2 : 0)], 10);
|
||||
if (connstate) {
|
||||
result.push({
|
||||
protocol: line[0],
|
||||
|
||||
Reference in New Issue
Block a user