Skip to content

Commit

Permalink
wg syncconf: explicitly reset PresharedKey/PersistentKeepalive
Browse files Browse the repository at this point in the history
make wg syncconf correctly clear a preshared key or keepalive in case
the file config does not define those; currently syncconf does not
change these settings at all if runtime has them set but file does not
  • Loading branch information
Andreas Weigel committed Apr 20, 2022
1 parent 1fd9570 commit 6477c83
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/setconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ static bool sync_conf(struct wgdevice *file)
}

for_each_wgpeer(file, peer) {
if (!(peer->flags & WGPEER_HAS_PRESHARED_KEY)) {
memset(peer->preshared_key, 0, WG_KEY_LEN);
peer->flags |= WGPEER_HAS_PRESHARED_KEY;
}
if (!(peer->flags & WGPEER_HAS_PERSISTENT_KEEPALIVE_INTERVAL)) {
peer->persistent_keepalive_interval = 0;
peer->flags |= WGPEER_HAS_PERSISTENT_KEEPALIVE_INTERVAL;
}
pubkeys[i].pubkey = peer->public_key;
pubkeys[i].from_file = true;
++i;
Expand Down

0 comments on commit 6477c83

Please sign in to comment.