]> PHS Git Server - phs-api.git/commitdiff
Testing vpn paths.
authorcharleswrayjr <charleswrayjr@gmail.com>
Mon, 8 Sep 2025 15:50:56 +0000 (10:50 -0500)
committercharleswrayjr <charleswrayjr@gmail.com>
Mon, 8 Sep 2025 15:50:56 +0000 (10:50 -0500)
src/controllers/vpn.controller.js

index cb3f9ad5d3972679b7dacb3dc419bb70a6a70640..374c8be674ff148b42e7d88bb5281c8dc46a82d4 100644 (file)
@@ -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 }` } );