wireguard: skip peer config if public key of the peer is not defined
authorFlorian Eckert <fe@dev.tdt.de>
Thu, 5 Dec 2019 10:33:38 +0000 (11:33 +0100)
committerJohn Crispin <john@phrozen.org>
Wed, 15 Jan 2020 20:19:01 +0000 (21:19 +0100)
If a config section of a peer does not have a public key defined, the
whole interface does not start. The following log is shown

daemon.notice netifd: test (21071): Line unrecognized: `PublicKey='
daemon.notice netifd: test (21071): Configuration parsing erro

The command 'wg show' does only show the interface name.

With this change we skip the peer for this interface and emit a log
message. So the other peers get configured.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
package/network/utils/wireguard-tools/files/wireguard.sh

index 4c811c6ba9a3fe7c5049c6400863cc167e7981cb..ccac34e45fa1e03183432795b26af3b822f2b2f5 100644 (file)
@@ -42,6 +42,11 @@ proto_wireguard_setup_peer() {
        config_get endpoint_port "${peer_config}" "endpoint_port"
        config_get persistent_keepalive "${peer_config}" "persistent_keepalive"
 
+       if [ -z "$public_key" ]; then
+               echo "Skipping peer config $peer_config because public key is not defined."
+               return 0
+       fi
+
        echo "[Peer]" >> "${wg_cfg}"
        echo "PublicKey=${public_key}" >> "${wg_cfg}"
        if [ "${preshared_key}" ]; then