Philip H.
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
4 additions and
4 deletions
-
src/lib/Server.js
-
src/lib/WireGuard.js
-
src/www/js/app.js
|
|
|
@ -123,7 +123,7 @@ module.exports = class Server { |
|
|
|
res.header('Content-Type', 'text/plain'); |
|
|
|
res.send(config); |
|
|
|
})) |
|
|
|
.post('/api/wireguard/client', Util.promisify(async req => { |
|
|
|
.post('/api/wireguard/client', Util.promisify(async (req) => { |
|
|
|
const { name, allowedIps } = req.body; |
|
|
|
return WireGuard.createClient({ name, allowedIps }); |
|
|
|
})) |
|
|
|
|
|
|
|
@ -232,11 +232,11 @@ Endpoint = ${WG_HOST}:${WG_PORT}`; |
|
|
|
|
|
|
|
let address; |
|
|
|
if (allowedIps) { |
|
|
|
address = allowedIps |
|
|
|
address = allowedIps; |
|
|
|
} else { |
|
|
|
// Calculate next IP
|
|
|
|
for (let i = 2; i < 255; i++) { |
|
|
|
const client = Object.values(config.clients).find(client => { |
|
|
|
const client = Object.values(config.clients).find((client) => { |
|
|
|
return client.address.includes(WG_DEFAULT_ADDRESS.replace('x', i)); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
@ -215,7 +215,7 @@ new Vue({ |
|
|
|
if (!name) return; |
|
|
|
|
|
|
|
this.api.createClient({ name, allowedIps }) |
|
|
|
.catch(err => alert(err.message || err.toString())) |
|
|
|
.catch((err) => alert(err.message || err.toString())) |
|
|
|
.finally(() => this.refresh().catch(console.error)); |
|
|
|
}, |
|
|
|
deleteClient(client) { |
|
|
|
|