From 4feaed1ae9826d939edc81fbdeb68ba4b295a73f Mon Sep 17 00:00:00 2001 From: charleswrayjr Date: Tue, 9 Sep 2025 09:12:33 -0500 Subject: [PATCH] Adding available clients to VPN. --- src/controllers/vpn.controller.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/controllers/vpn.controller.js b/src/controllers/vpn.controller.js index 31e64e7..fe10bd6 100644 --- a/src/controllers/vpn.controller.js +++ b/src/controllers/vpn.controller.js @@ -149,6 +149,7 @@ module.exports = { const commands = [ `ls /etc/openvpn/ccd/* 2>/dev/null || true`, `ls /etc/openvpn/easy-rsa/pki/issued/*.crt 2>/dev/null || true`, + 'ls /home/node/clients/* 2>/dev/null || true' ]; conn.exec( commands.join( ' && ' ), ( err, stream ) => { if (err) { @@ -166,9 +167,10 @@ module.exports = { } console.log(output); const clients = []; - const ccdFiles = output.split('\n').filter(line => !line.endsWith('.crt')).filter( l => !l.startsWith('.') && l !== '' && !l.endsWith('server')); + const ccdFiles = output.split('\n').filter(line => !line.endsWith('.crt') && !line.endsWith('.ovpn')).filter( l => !l.startsWith('.') && l !== '' && !l.endsWith('server')); const crtFiles = output.split('\n').filter(line => line.endsWith('.crt')).filter( l => !l.startsWith('.') && l !== '' && !l.endsWith('server.crt')); - + const ovpnFiles = output.split('\n').filter(line => line.endsWith('.ovpn')).filter( l => !l.startsWith('.') && l !== ''); + console.log(ovpnFiles); console.log(ccdFiles); console.log(crtFiles); @@ -183,10 +185,14 @@ module.exports = { logger.warn( `staticIpMatch: ${ staticIpMatch }`); const hasCrt = crtFiles.some( crt => crt.includes( `${ clientName }.crt` ) ); logger.warn(`hasCrt: ${ hasCrt }`); + const hasOvpn = ovpnFiles.some( ovpn => ovpn.includes( `${ clientName }.ovpn` ) ); + const ovpnPath = `/home/node/clients/${ clientName }.ovpn`; clients.push( { clientName, staticIp:staticIpMatch ? staticIpMatch[1] : null, hasCertificate:hasCrt, + hasOvpn:hasOvpn, + ovpnPath } ); } catch (error) { logger.warn( `Failed to read ${ ccdFile }: ${ error.message }` ); -- 2.43.0