Browse Source

Adding support for Table setting

Setting is explained here https://man7.org/linux/man-pages/man8/wg-quick.8.html
pull/505/head
Kristof Ringleff, Fooman 3 years ago
parent
commit
16f3fba3e5
  1. 1
      README.md
  2. 1
      src/config.js
  3. 6
      src/lib/WireGuard.js

1
README.md

@ -85,6 +85,7 @@ 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_PORT` | `51820` | `12345` | The public UDP port of your VPN server. WireGuard will always listen on `51820` inside the Docker container. |
| `WG_MTU` | `null` | `1420` | The MTU the clients will use. Server uses default WG MTU. |
| `WG_TABLE` | `null` | `1234` | Controls the routing table to which routes are added. There are two special values: `off` disables the creation of routes altogether, and `auto` adds routes to the default table and enables special handling of default routes. |
| `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. |

1
src/config.js

@ -9,6 +9,7 @@ module.exports.WG_PATH = process.env.WG_PATH || '/etc/wireguard/';
module.exports.WG_HOST = process.env.WG_HOST;
module.exports.WG_PORT = process.env.WG_PORT || 51820;
module.exports.WG_MTU = process.env.WG_MTU || null;
module.exports.WG_TABLE = process.env.WG_TABLE || null;
module.exports.WG_PERSISTENT_KEEPALIVE = process.env.WG_PERSISTENT_KEEPALIVE || 0;
module.exports.WG_DEFAULT_ADDRESS = process.env.WG_DEFAULT_ADDRESS || '10.8.0.x';
module.exports.WG_DEFAULT_DNS = typeof process.env.WG_DEFAULT_DNS === 'string'

6
src/lib/WireGuard.js

@ -15,6 +15,7 @@ const {
WG_HOST,
WG_PORT,
WG_MTU,
WG_TABLE,
WG_DEFAULT_DNS,
WG_DEFAULT_ADDRESS,
WG_PERSISTENT_KEEPALIVE,
@ -102,6 +103,11 @@ PreDown = ${WG_PRE_DOWN}
PostDown = ${WG_POST_DOWN}
`;
if (WG_TABLE) {
result += `
Table = ${WG_TABLE}
`;
}
for (const [clientId, client] of Object.entries(config.clients)) {
if (!client.enabled) continue;

Loading…
Cancel
Save