allow edit of name + address

This commit is contained in:
Emile Nijssen 2021-07-13 20:51:23 +02:00
parent 2966666cc6
commit 016382dd01
11 changed files with 221 additions and 205 deletions

View file

@ -266,4 +266,26 @@ Endpoint = ${WG_HOST}:${WG_PORT}`;
await this.saveConfig();
}
async updateClientName({ clientId, name }) {
const client = await this.getClient({ clientId });
client.name = name;
client.updatedAt = new Date();
await this.saveConfig();
}
async updateClientAddress({ clientId, address }) {
const client = await this.getClient({ clientId });
if (!Util.isValidIPv4(address)) {
throw new ServerError(`Invalid Address: ${address}`, 400);
}
client.address = address;
client.updatedAt = new Date();
await this.saveConfig();
}
};