xwvike
3 years ago
committed by
Julien COSMAO
No known key found for this signature in database
GPG Key ID: 69153421048939E2
3 changed files with
21 additions and
21 deletions
-
src/lib/WireGuard.js
-
src/www/js/api.js
-
src/www/js/app.js
|
|
|
@ -336,7 +336,6 @@ Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`; |
|
|
|
throw new ServerError(`Invalid Address: ${address}`, 400); |
|
|
|
} |
|
|
|
if (client?.allowedIPs) { |
|
|
|
let allowedIPs = client.allowedIPs |
|
|
|
client.allowedIPs[0].address = address; |
|
|
|
} |
|
|
|
client.address = address; |
|
|
|
@ -344,14 +343,15 @@ Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`; |
|
|
|
|
|
|
|
await this.saveConfig(); |
|
|
|
} |
|
|
|
|
|
|
|
async updateClientAllowedIPs({ clientId, allowedIPs }) { |
|
|
|
const client = await this.getClient({ clientId }); |
|
|
|
let ips = allowedIPs.map(item=>item.address) |
|
|
|
ips.forEach(ip=>{ |
|
|
|
const ips = allowedIPs.map((item) => item.address); |
|
|
|
ips.forEach((ip) => { |
|
|
|
if (!Util.isValidIPv4(ip)) { |
|
|
|
throw new ServerError(`Invalid Address: ${ip}`, 400); |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
client.allowedIPs = allowedIPs; |
|
|
|
client.updatedAt = new Date(); |
|
|
|
|
|
|
|
|
|
|
|
@ -137,6 +137,7 @@ class API { |
|
|
|
body: { address }, |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
async updateClientAllowedIPs({ clientId, allowedIPs }) { |
|
|
|
return this.call({ |
|
|
|
method: 'put', |
|
|
|
@ -145,7 +146,6 @@ class API { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async restoreConfiguration(file) { |
|
|
|
return this.call({ |
|
|
|
method: 'put', |
|
|
|
|
|
|
|
@ -325,15 +325,15 @@ new Vue({ |
|
|
|
.finally(() => this.refresh().catch(console.error)); |
|
|
|
}, |
|
|
|
addNewIP() { |
|
|
|
let address = this.userInputIP.slice(0,4).join('.'); |
|
|
|
let allowedIPs = this.clientEditAllowedIPs.allowedIPs; |
|
|
|
let obj = {type:'ipv4', address, cidr: this.userInputIP[4]}; |
|
|
|
const address = this.userInputIP.slice(0, 4).join('.'); |
|
|
|
const allowedIPs = [...this.clientEditAllowedIPs.allowedIPs]; |
|
|
|
const obj = { type: 'ipv4', address, cidr: this.userInputIP[4] }; |
|
|
|
allowedIPs.push(obj); |
|
|
|
this.clientEditAllowedIPs.allowedIPs = allowedIPs; |
|
|
|
this.userInputIP = [0, 0, 0, 0, 0]; |
|
|
|
}, |
|
|
|
removeIP(index) { |
|
|
|
let allowedIPs = this.clientEditAllowedIPs.allowedIPs; |
|
|
|
const allowedIPs = [...this.clientEditAllowedIPs.allowedIPs]; |
|
|
|
allowedIPs.splice(index, 1); |
|
|
|
this.clientEditAllowedIPs.allowedIPs = allowedIPs; |
|
|
|
}, |
|
|
|
|