From 4ce21686d7c5a6cc9cc911012fc46bf3810995d4 Mon Sep 17 00:00:00 2001 From: Lee *!* Clagett Date: Wed, 2 Aug 2023 15:52:47 -0400 Subject: [PATCH] Add config-file option (#77) --- src/server_main.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/server_main.cpp b/src/server_main.cpp index 4eda9d0..1e52be3 100644 --- a/src/server_main.cpp +++ b/src/server_main.cpp @@ -43,6 +43,7 @@ #include "config.h" #include "cryptonote_config.h" // monero/src/ #include "db/storage.h" +#include "error.h" #include "options.h" #include "rest_server.h" #include "scanner.h" @@ -70,6 +71,7 @@ namespace const command_line::arg_descriptor log_level; const command_line::arg_descriptor disable_admin_auth; const command_line::arg_descriptor webhook_ssl_verification; + const command_line::arg_descriptor config_file; static std::string get_default_zmq() { @@ -105,6 +107,7 @@ namespace , log_level{"log-level", "Log level [0-4]", 1} , disable_admin_auth{"disable-admin-auth", "Make auth field optional in HTTP-REST requests", false} , webhook_ssl_verification{"webhook-ssl-verification", "[] specify SSL verification mode for webhooks", "system_ca"} + , config_file{"config-file", "Specify any option in a config file; = on separate lines"} {} void prepare(boost::program_options::options_description& description) const @@ -128,6 +131,7 @@ namespace command_line::add_arg(description, log_level); command_line::add_arg(description, disable_admin_auth); command_line::add_arg(description, webhook_ssl_verification); + command_line::add_arg(description, config_file); } }; @@ -169,6 +173,18 @@ namespace po::command_line_parser(argc, argv).options(description).run(), args ); po::notify(args); + + if (!command_line::is_arg_defaulted(args, opts.config_file)) + { + boost::filesystem::path config_path{command_line::get_arg(args, opts.config_file)}; + if (!boost::filesystem::exists(config_path)) + MONERO_THROW(lws::error::configuration, "Config file does not exist"); + + po::store( + po::parse_config_file(config_path.string().c_str(), description), args + ); + po::notify(args); + } } if (command_line::get_arg(args, command_line::arg_help))