wg: setconf should remove existing psk

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2017-01-24 04:11:56 +01:00
parent 4586e14749
commit 666623a82e
1 changed files with 3 additions and 0 deletions

View File

@ -370,6 +370,9 @@ bool config_read_finish(struct config_ctx *ctx)
fprintf(stderr, "No private key configured\n"); fprintf(stderr, "No private key configured\n");
goto err; goto err;
} }
if (ctx->buf.dev->flags & WGDEVICE_REPLACE_PEERS && !key_is_valid(ctx->buf.dev->preshared_key))
ctx->buf.dev->flags |= WGDEVICE_REMOVE_PRESHARED_KEY;
for_each_wgpeer(ctx->buf.dev, peer, i) { for_each_wgpeer(ctx->buf.dev, peer, i) {
if (!key_is_valid(peer->public_key)) { if (!key_is_valid(peer->public_key)) {
fprintf(stderr, "A peer is missing a public key\n"); fprintf(stderr, "A peer is missing a public key\n");