diff --git a/README.md b/README.md index 8294e4a4..b27ef9f3 100644 --- a/README.md +++ b/README.md @@ -109,12 +109,12 @@ These options can be configured by setting environment variables using `-e KEY=" | `WG_HOST` | - | `vpn.myserver.com` | The public hostname of your VPN server. | | `WG_DEVICE` | `eth0` | `ens6f0` | Ethernet device the wireguard traffic should be forwarded through. | | `WG_PORT` | `51820` | `12345` | The public UDP port of your VPN server. WireGuard will listen on that (othwise default) inside the Docker container. | -| `WG_CONFIG_PORT`| `51820` | `12345` | The UDP port used on [Home Assistant Plugin](https://github.com/adriy-be/homeassistant-addons-jdeath/tree/main/wgeasy) +| `WG_CONFIG_PORT`| `51820` | `12345` | The UDP port used on [Home Assistant Plugin](https://github.com/adriy-be/homeassistant-addons-jdeath/tree/main/wgeasy) | `WG_MTU` | `null` | `1420` | The MTU the clients will use. Server uses default WG MTU. | | `WG_PERSISTENT_KEEPALIVE` | `0` | `25` | Value in seconds to keep the "connection" open. If this value is 0, then connections won't be kept alive. | | `WG_DEFAULT_ADDRESS` | `10.8.0.x` | `10.6.0.x` | Clients IP address range. | | `WG_DEFAULT_DNS` | `1.1.1.1` | `8.8.8.8, 8.8.4.4` | DNS server clients will use. If set to blank value, clients will not use any DNS. | -| `WG_ALLOWED_IPS` | `0.0.0.0/0, ::/0` | `192.168.15.0/24, 10.0.1.0/24` | Allowed IPs clients will use. | +| `WG_ALLOWED_IPS` | `0.0.0.0/0, ::/0` | `192.168.15.0/24, 10.0.1.0/24` | Allowed IPs clients will use. It specify which destination address will be routed to wireguard interface. | | `WG_PRE_UP` | `...` | - | See [config.js](https://github.com/wg-easy/wg-easy/blob/master/src/config.js#L19) for the default value. | | `WG_POST_UP` | `...` | `iptables ...` | See [config.js](https://github.com/wg-easy/wg-easy/blob/master/src/config.js#L20) for the default value. | | `WG_PRE_DOWN` | `...` | - | See [config.js](https://github.com/wg-easy/wg-easy/blob/master/src/config.js#L27) for the default value. | diff --git a/src/lib/Server.js b/src/lib/Server.js index cd00782a..80810368 100644 --- a/src/lib/Server.js +++ b/src/lib/Server.js @@ -191,8 +191,8 @@ module.exports = class Server { return config; })) .post('/api/wireguard/client', defineEventHandler(async (event) => { - const { name, allowedIps } = await readBody(event); - await WireGuard.createClient({ name, allowedIps }); + const { name } = await readBody(event); + await WireGuard.createClient({ name }); return { success: true }; })) .delete('/api/wireguard/client/:clientId', defineEventHandler(async (event) => { @@ -234,7 +234,7 @@ module.exports = class Server { await WireGuard.updateClientAddress({ clientId, address }); return { success: true }; })) - .put('/api/wireguard/client/:clientId/allowedips', defineEventHandler(async (event) => { + .put('/api/wireguard/client/:clientId/allowedIPs', defineEventHandler(async (event) => { const clientId = getRouterParam(event, 'clientId'); if (clientId === '__proto__' || clientId === 'constructor' || clientId === 'prototype') { throw createError({ status: 403 }); @@ -242,7 +242,7 @@ module.exports = class Server { const { allowedIPs } = await readBody(event); await WireGuard.updateClientAllowedIPs({ clientId, allowedIPs }); return { success: true }; - })) + })); const safePathJoin = (base, target) => { // Manage web root (edge case) diff --git a/src/lib/WireGuard.js b/src/lib/WireGuard.js index 9db73def..dfc091ad 100644 --- a/src/lib/WireGuard.js +++ b/src/lib/WireGuard.js @@ -117,7 +117,7 @@ PostDown = ${WG_POST_DOWN} } allowedIPs = allowedIPs.substring(1); } else { - allowedIPs = client.address; + allowedIPs = `${client.address}/32`; } result += ` @@ -235,7 +235,7 @@ Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`; }); } - async createClient({ name, allowedIps }) { + async createClient({ name }) { if (!name) { throw new Error('Missing: Name'); } @@ -248,20 +248,16 @@ Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`; }); const preSharedKey = await Util.exec('wg genpsk'); + // Calculate next IP let address; - if (allowedIps) { - address = allowedIps; - } else { - // Calculate next IP - for (let i = 2; i < 255; i++) { - const client = Object.values(config.clients).find((client) => { - return client.address.includes(WG_DEFAULT_ADDRESS.replace('x', i)); - }); + for (let i = 2; i < 255; i++) { + const client = Object.values(config.clients).find((client) => { + return client.address.includes(WG_DEFAULT_ADDRESS.replace('x', i)); + }); - if (!client) { - address = `${WG_DEFAULT_ADDRESS.replace('x', i)}`; - break; - } + if (!client) { + address = `${WG_DEFAULT_ADDRESS.replace('x', i)}`; + break; } } diff --git a/src/www/css/app.css b/src/www/css/app.css index fbaf3a81..733caef8 100644 --- a/src/www/css/app.css +++ b/src/www/css/app.css @@ -843,6 +843,10 @@ video { height: 2rem; } +.h-9 { + height: 2.25rem; +} + .min-h-5 { min-height: 1.25rem; } @@ -887,6 +891,10 @@ video { width: 2rem; } +.w-9 { + width: 2.25rem; +} + .w-fit { width: -moz-fit-content; width: fit-content; diff --git a/src/www/index.html b/src/www/index.html index 530fde2c..08cacfbe 100644 --- a/src/www/index.html +++ b/src/www/index.html @@ -112,7 +112,7 @@ {{$t("backup")}} -
-- -
-