From: charleswrayjr Date: Mon, 8 Sep 2025 16:12:31 +0000 (-0500) Subject: Testing vpn paths. X-Git-Url: https://git.phasecustomsoft.com/static/js/%7B?a=commitdiff_plain;h=9c528e10198d1813cdfb1f6fbe95c59511b5f13c;p=phs-api.git Testing vpn paths. --- diff --git a/src/controllers/vpn.controller.js b/src/controllers/vpn.controller.js index 642126a..ebac448 100644 --- a/src/controllers/vpn.controller.js +++ b/src/controllers/vpn.controller.js @@ -88,7 +88,9 @@ module.exports = { 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; @@ -98,6 +100,8 @@ module.exports = { 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 []; @@ -113,6 +117,8 @@ module.exports = { }); } + console.log('clientsMap: ', clientsMap); + // Assign virtual IPs for (let i = mIndex + 2; i < eIndex; i++) { const parts = lines[i].split(','); @@ -120,6 +126,8 @@ module.exports = { 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' ) );