|
|
@ -327,7 +327,6 @@ Endpoint = ${WG_HOST}:${WG_PORT}`; |
|
|
throw new ServerError(`Invalid Address: ${address}`, 400); |
|
|
throw new ServerError(`Invalid Address: ${address}`, 400); |
|
|
} |
|
|
} |
|
|
if (client?.allowedIPs) { |
|
|
if (client?.allowedIPs) { |
|
|
let allowedIPs = client.allowedIPs |
|
|
|
|
|
client.allowedIPs[0].address = address; |
|
|
client.allowedIPs[0].address = address; |
|
|
} |
|
|
} |
|
|
client.address = address; |
|
|
client.address = address; |
|
|
@ -335,14 +334,15 @@ Endpoint = ${WG_HOST}:${WG_PORT}`; |
|
|
|
|
|
|
|
|
await this.saveConfig(); |
|
|
await this.saveConfig(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async updateClientAllowedIPs({ clientId, allowedIPs }) { |
|
|
async updateClientAllowedIPs({ clientId, allowedIPs }) { |
|
|
const client = await this.getClient({ clientId }); |
|
|
const client = await this.getClient({ clientId }); |
|
|
let ips = allowedIPs.map(item=>item.address) |
|
|
const ips = allowedIPs.map((item) => item.address); |
|
|
ips.forEach(ip=>{ |
|
|
ips.forEach((ip) => { |
|
|
if (!Util.isValidIPv4(ip)) { |
|
|
if (!Util.isValidIPv4(ip)) { |
|
|
throw new ServerError(`Invalid Address: ${ip}`, 400); |
|
|
throw new ServerError(`Invalid Address: ${ip}`, 400); |
|
|
} |
|
|
} |
|
|
}) |
|
|
}); |
|
|
client.allowedIPs = allowedIPs; |
|
|
client.allowedIPs = allowedIPs; |
|
|
client.updatedAt = new Date(); |
|
|
client.updatedAt = new Date(); |
|
|
|
|
|
|
|
|
|