[PATCH 2/2] recognize and ignore commands used by wg-quick

Michael Tokarev mjt at tls.msk.ru
Mon Jan 18 10:08:02 UTC 2021


When reading the config file, recognize and ignore commands in the [Interface] section
which are used by wg-qukck. This way wg-quick config file can be read by wg too directly
so there's no need to filter it out by wg-quick and it's easy to reload configuration too.

Signed-off-by: Michael Tokarev <mjt at tls.msk.ru>
---
 src/config.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/config.c b/src/config.c
index b4280e5..0095556 100644
--- a/src/config.c
+++ b/src/config.c
@@ -460,6 +460,10 @@ static bool process_line(struct config_ctx *ctx, const char *line)
 			ret = parse_key_or_file(ctx->device->private_key, value);
 			if (ret)
 				ctx->device->flags |= WGDEVICE_HAS_PRIVATE_KEY;
+		} else if (key_match("Address") || key_match("DNS") || key_match("MTU") || key_match("Table") ||
+		           key_match("PreUp") || key_match("PostUp") || key_match("PreDown") || key_match("PostDown") ||
+		           key_match("SaveConfig")) {
+			/* ignore commands used by wg-quick */
 		} else
 			goto error;
 	} else if (ctx->is_peer_section) {
-- 
2.20.1



More information about the WireGuard mailing list