mirror of
https://github.com/vtnerd/monero-lws.git
synced 2024-11-16 17:27:39 +00:00
Add config-file option (#77)
This commit is contained in:
parent
5e2936faee
commit
4ce21686d7
1 changed files with 16 additions and 0 deletions
|
@ -43,6 +43,7 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "cryptonote_config.h" // monero/src/
|
#include "cryptonote_config.h" // monero/src/
|
||||||
#include "db/storage.h"
|
#include "db/storage.h"
|
||||||
|
#include "error.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "rest_server.h"
|
#include "rest_server.h"
|
||||||
#include "scanner.h"
|
#include "scanner.h"
|
||||||
|
@ -70,6 +71,7 @@ namespace
|
||||||
const command_line::arg_descriptor<unsigned short> log_level;
|
const command_line::arg_descriptor<unsigned short> log_level;
|
||||||
const command_line::arg_descriptor<bool> disable_admin_auth;
|
const command_line::arg_descriptor<bool> disable_admin_auth;
|
||||||
const command_line::arg_descriptor<std::string> webhook_ssl_verification;
|
const command_line::arg_descriptor<std::string> webhook_ssl_verification;
|
||||||
|
const command_line::arg_descriptor<std::string> config_file;
|
||||||
|
|
||||||
static std::string get_default_zmq()
|
static std::string get_default_zmq()
|
||||||
{
|
{
|
||||||
|
@ -105,6 +107,7 @@ namespace
|
||||||
, log_level{"log-level", "Log level [0-4]", 1}
|
, log_level{"log-level", "Log level [0-4]", 1}
|
||||||
, disable_admin_auth{"disable-admin-auth", "Make auth field optional in HTTP-REST requests", false}
|
, disable_admin_auth{"disable-admin-auth", "Make auth field optional in HTTP-REST requests", false}
|
||||||
, webhook_ssl_verification{"webhook-ssl-verification", "[<none|system_ca>] specify SSL verification mode for webhooks", "system_ca"}
|
, webhook_ssl_verification{"webhook-ssl-verification", "[<none|system_ca>] specify SSL verification mode for webhooks", "system_ca"}
|
||||||
|
, config_file{"config-file", "Specify any option in a config file; <name>=<value> on separate lines"}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void prepare(boost::program_options::options_description& description) const
|
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, log_level);
|
||||||
command_line::add_arg(description, disable_admin_auth);
|
command_line::add_arg(description, disable_admin_auth);
|
||||||
command_line::add_arg(description, webhook_ssl_verification);
|
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::command_line_parser(argc, argv).options(description).run(), args
|
||||||
);
|
);
|
||||||
po::notify(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<char>(config_path.string<std::string>().c_str(), description), args
|
||||||
|
);
|
||||||
|
po::notify(args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command_line::get_arg(args, command_line::arg_help))
|
if (command_line::get_arg(args, command_line::arg_help))
|
||||||
|
|
Loading…
Reference in a new issue