@ -43,7 +43,6 @@ class WireGuard {
}
}
debug ( 'Loading configuration...' ) ;
debug ( 'Loading configuration...' ) ;
// TODO: Better way to invalidate cache
this . # configCache = null ;
this . # configCache = null ;
try {
try {
const config = await fs . readFile ( path . join ( WG_PATH , 'wg0.json' ) , 'utf8' ) ;
const config = await fs . readFile ( path . join ( WG_PATH , 'wg0.json' ) , 'utf8' ) ;
@ -261,7 +260,7 @@ Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`;
expireDate ,
expireDate ,
} : {
} : {
name : string ;
name : string ;
expireDate : string ;
expireDate : string | null ;
} ) {
} ) {
if ( ! name ) {
if ( ! name ) {
throw new Error ( 'Missing: Name' ) ;
throw new Error ( 'Missing: Name' ) ;
@ -418,7 +417,7 @@ Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`;
expireDate ,
expireDate ,
} : {
} : {
clientId : string ;
clientId : string ;
expireDate : string ;
expireDate : string | null ;
} ) {
} ) {
const client = await this . getClient ( { clientId } ) ;
const client = await this . getClient ( { clientId } ) ;
@ -577,13 +576,13 @@ Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`;
}
}
const inst = new WireGuard ( ) ;
const inst = new WireGuard ( ) ;
inst . getConfig ( ) . catch ( ( err ) = > {
console . error ( err ) ;
process . exit ( 1 ) ;
} ) ;
// This also has to also start the WireGuard Server
async function cronJobEveryMinute() {
async function cronJobEveryMinute() {
await inst . cronJobEveryMinute ( ) ;
await inst . cronJobEveryMinute ( ) . catch ( ( err ) = > {
debug ( 'Running Cron Job failed.' ) ;
console . error ( err ) ;
} ) ;
setTimeout ( cronJobEveryMinute , 60 * 1000 ) ;
setTimeout ( cronJobEveryMinute , 60 * 1000 ) ;
}
}
cronJobEveryMinute ( ) ;
cronJobEveryMinute ( ) ;