Browse Source

responce added to apis

pull/468/head
tm-sanjay 4 years ago
parent
commit
2b378d0d6f
  1. 14
      src/lib/WireGuard.js

14
src/lib/WireGuard.js

@ -292,25 +292,35 @@ Endpoint = ${WG_HOST}:${WG_PORT}`;
if (config.clients[clientId]) { if (config.clients[clientId]) {
delete config.clients[clientId]; delete config.clients[clientId];
await this.saveConfig(); await this.saveConfig();
return {status: 'Client Deleted'};
} }
return {status: 'Client Not Found'};
} }
async enableClient({ clientId }) { async enableClient({ clientId }) {
const client = await this.getClient({ clientId }); const client = await this.getClient({ clientId });
if (client) {
client.enabled = true; client.enabled = true;
client.updatedAt = new Date(); client.updatedAt = new Date();
await this.saveConfig(); await this.saveConfig();
return {status: 'Client Enabled'};
}
return {status: 'Client Not Found'};
} }
async disableClient({ clientId }) { async disableClient({ clientId }) {
const client = await this.getClient({ clientId }); const client = await this.getClient({ clientId });
if (client) {
client.enabled = false; client.enabled = false;
client.updatedAt = new Date(); client.updatedAt = new Date();
await this.saveConfig(); await this.saveConfig();
return {status: 'Client Disabled'};
}
return {status: 'Client Not Found'};
} }
async updateClientName({ clientId, name }) { async updateClientName({ clientId, name }) {
@ -320,6 +330,8 @@ Endpoint = ${WG_HOST}:${WG_PORT}`;
client.updatedAt = new Date(); client.updatedAt = new Date();
await this.saveConfig(); await this.saveConfig();
return {status: 'Client Name Updated'};
} }
async updateClientAddress({ clientId, address }) { async updateClientAddress({ clientId, address }) {
@ -333,6 +345,8 @@ Endpoint = ${WG_HOST}:${WG_PORT}`;
client.updatedAt = new Date(); client.updatedAt = new Date();
await this.saveConfig(); await this.saveConfig();
return {status: 'Client Address Updated'};
} }
}; };

Loading…
Cancel
Save