summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/fastd.c11
-rw-r--r--src/fastd.h1
-rw-r--r--src/options.c4
-rw-r--r--src/options.def.h1
4 files changed, 14 insertions, 3 deletions
diff --git a/src/fastd.c b/src/fastd.c
index 532c8be..9115bbf 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -896,10 +896,12 @@ int main(int argc, char *argv[]) {
init_signals(&ctx);
- if (conf.daemon)
- status_fd = daemonize(&ctx);
+ if (!conf.verify_config) {
+ if (conf.daemon)
+ status_fd = daemonize(&ctx);
- init_log(&ctx);
+ init_log(&ctx);
+ }
#ifdef HAVE_LIBSODIUM
sodium_init();
@@ -913,6 +915,9 @@ int main(int argc, char *argv[]) {
fastd_config_check(&ctx, &conf);
+ if (conf.verify_config)
+ exit(0);
+
update_time(&ctx);
ctx.next_keepalives = fastd_in_seconds(&ctx, conf.keepalive_interval);
diff --git a/src/fastd.h b/src/fastd.h
index 219dc2e..bad7e66 100644
--- a/src/fastd.h
+++ b/src/fastd.h
@@ -242,6 +242,7 @@ struct fastd_config {
bool machine_readable;
bool generate_key;
bool show_key;
+ bool verify_config;
};
struct fastd_context {
diff --git a/src/options.c b/src/options.c
index 7175c20..d30dde6 100644
--- a/src/options.c
+++ b/src/options.c
@@ -319,6 +319,10 @@ static void option_on_verify(fastd_context_t *ctx UNUSED, fastd_config_t *conf,
#endif
+static void option_verify_config(fastd_context_t *ctx UNUSED, fastd_config_t *conf) {
+ conf->verify_config = true;
+}
+
static void option_generate_key(fastd_context_t *ctx UNUSED, fastd_config_t *conf) {
conf->generate_key = true;
conf->show_key = false;
diff --git a/src/options.def.h b/src/options.def.h
index af07c45..8a85751 100644
--- a/src/options.def.h
+++ b/src/options.def.h
@@ -46,6 +46,7 @@ OPTION_ARG(option_on_verify, "--on-verify", "<command>", "Sets a shell command t
SEPARATOR;
#endif
+OPTION(option_verify_config, "--verify-config", "Checks the configuration and exits");
OPTION(option_generate_key, "--generate-key", "Generates a new keypair");
OPTION(option_show_key, "--show-key", "Shows the public key corresponding to the configured secret");
OPTION(option_machine_readable, "--machine-readable", "Suppresses output of explaining text in the --show-key and --generate-key commands");