if (code !== 0) {
return next(new createError(500, `Command failed: ${output}`));
}
- console.log(output);
const clients = [];
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);
// Process .ccd files for static IPs
for (const ccdFile of ccdFiles) {
const clientName = path.basename( ccdFile, '' );
- logger.warn( `Processing ${ ccdFile } with clientName ${ clientName }`);
try {
const ccdContent = fs.readFileSync( ccdFile, 'utf8' );
- logger.warn( `ccdContent: ${ ccdContent }`);
const staticIpMatch = ccdContent.match( /ifconfig-push (\S+)/ );
- 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` ) );
- logger.warn(`hasOvpn: ${ hasOvpn }`);
clients.push( {
clientName,
staticIp:staticIpMatch ? staticIpMatch[1] : null,