Browse Source

Added option to enforce AllowedIPs

pull/493/head
BrainStone 3 years ago
parent
commit
e987bde456
  1. 1
      README.md
  2. 1
      src/config.js
  3. 9
      src/lib/WireGuard.js

1
README.md

@ -89,6 +89,7 @@ These options can be configured by setting environment variables using `-e KEY="
| `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. |
| `WG_ALLOWED_IPS` | `0.0.0.0/0, ::/0` | `192.168.15.0/24, 10.0.1.0/24` | Allowed IPs clients will use. |
| `ENFORCE_WG_ALLOWED_IPS` | `false` | `true` | If enabled, we restrict the clients to `WG_ALLOWED_IPS`. As the clients are able to change their allowed IPs, this will prevent them from accessing anything outside what they are supposed to. |
| `WG_PRE_UP` | `...` | - | See [config.js](https://github.com/WeeJeWel/wg-easy/blob/master/src/config.js#L19) for the default value. |
| `WG_POST_UP` | `...` | `iptables ...` | See [config.js](https://github.com/WeeJeWel/wg-easy/blob/master/src/config.js#L20) for the default value. |
| `WG_PRE_DOWN` | `...` | - | See [config.js](https://github.com/WeeJeWel/wg-easy/blob/master/src/config.js#L27) for the default value. |

1
src/config.js

@ -15,6 +15,7 @@ module.exports.WG_DEFAULT_DNS = typeof process.env.WG_DEFAULT_DNS === 'string'
? process.env.WG_DEFAULT_DNS
: '1.1.1.1';
module.exports.WG_ALLOWED_IPS = process.env.WG_ALLOWED_IPS || '0.0.0.0/0, ::/0';
module.exports.ENFORCE_WG_ALLOWED_IPS = Boolean(process.env.ENFORCE_WG_ALLOWED_IPS || false);
module.exports.WG_PRE_UP = process.env.WG_PRE_UP || '';
module.exports.WG_POST_UP = process.env.WG_POST_UP || `

9
src/lib/WireGuard.js

@ -19,6 +19,7 @@ const {
WG_DEFAULT_ADDRESS,
WG_PERSISTENT_KEEPALIVE,
WG_ALLOWED_IPS,
ENFORCE_WG_ALLOWED_IPS,
WG_PRE_UP,
WG_POST_UP,
WG_PRE_DOWN,
@ -96,7 +97,13 @@ module.exports = class WireGuard {
PrivateKey = ${config.server.privateKey}
Address = ${config.server.address}/24
ListenPort = 51820
PreUp = ${WG_PRE_UP}
`;
if (ENFORCE_WG_ALLOWED_IPS) {
result += `AllowedIPs = ${WG_ALLOWED_IPS}\n`;
}
result += `PreUp = ${WG_PRE_UP}
PostUp = ${WG_POST_UP}
PreDown = ${WG_PRE_DOWN}
PostDown = ${WG_POST_DOWN}

Loading…
Cancel
Save