From: charleswrayjr Date: Mon, 8 Sep 2025 15:50:56 +0000 (-0500) Subject: Testing vpn paths. X-Git-Url: https://git.phasecustomsoft.com/?a=commitdiff_plain;h=da4fa75f7afa28f3bc176e1ff2bff7eef2c5db5b;p=phs-api.git Testing vpn paths. --- diff --git a/src/controllers/vpn.controller.js b/src/controllers/vpn.controller.js index cb3f9ad..374c8be 100644 --- a/src/controllers/vpn.controller.js +++ b/src/controllers/vpn.controller.js @@ -87,21 +87,17 @@ module.exports = { stream.on( 'close', ( code ) => { conn.end(); if (code === 0) { - console.log( 'output: ', output ); const lines = output.split( '\n' ); const sIndex = lines.findIndex( line => line.startsWith( 'Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since' ) ); const eIndex = lines.findIndex( line => line.startsWith( 'ROUTING TABLE' ) ); + const C = [...lines].slice(sIndex +1, eIndex).filter( line => line.trim() ); + const R = [...lines].slice(eIndex + lines.length).filter( line => line.trim() ); + console.log('clients: ', C, ' routes: ', R ); const clients = lines.slice( sIndex + 1, eIndex ).map( line => { const parts = line.split( ',' ); - console.log( 'parts: ', parts ); const vLine = lines.find( l => l.includes( parts[0] ) && l !== line ); - console.log( 'vLine: ', vLine ); return { name:parts[0], ip:parts[1], virtual_ip:vLine.split( ',' )[0], connectedSince:parts[4] }; } ); - /*const clients = output.split( '\n' ).filter( line => line.startsWith( 'Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since' ) ).map( line => { - const parts = line.split( ',' ); - return { name:parts[1], ip:parts[2], connectedSince:parts[8] }; - } );*/ res.json( { clients } ); } else { res.status( 500 ).json( { error:`Command failed: ${ output }` } );