conn.end();
if (code === 0) {
// Split once and reuse
- const lines = output.split('\n').map(line => line.trim()).filter(Boolean);
+ const lines = output.split('\n').map(line => line.trim());
+
+ console.log('lines: ', lines);
// Find indices using a single pass
let sIndex = -1, mIndex = -1, eIndex = -1;
else if (eIndex === -1 && line.startsWith('GLOBAL STATS')) eIndex = i;
});
+ console.log('indexes: ', sIndex, mIndex, eIndex);
+
// Early return if indices not found
if (sIndex === -1 || mIndex === -1 || eIndex === -1) return [];
});
}
+ console.log('clientsMap: ', clientsMap);
+
// Assign virtual IPs
for (let i = mIndex + 2; i < eIndex; i++) {
const parts = lines[i].split(',');
if (client) client.virtual_ip = parts[0];
}
+ console.log('clientsMap: ', clientsMap);
+
res.json(clientsMap.values());
/*const lines = output.split( '\n' );
const sIndex = lines.findIndex( line => line.startsWith( 'Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since' ) );