26 : http_host_(
""), http_port_(0), http_headers_(),
27 trust_anchor_(
""), cert_file_(
""), key_file_(
""), cert_required_(true) {
31 :
ConfigBase(), ctrl_sockets_(orig.ctrl_sockets_),
32 http_host_(orig.http_host_), http_port_(orig.http_port_),
33 http_headers_(orig.http_headers_),
34 trust_anchor_(orig.trust_anchor_), cert_file_(orig.cert_file_),
35 key_file_(orig.key_file_), cert_required_(orig.cert_required_),
36 hooks_config_(orig.hooks_config_), auth_config_(orig.auth_config_) {
53 s <<
"listening on " << ctx->getHttpHost() <<
", port "
54 << ctx->getHttpPort();
57 if (!ctx->getTrustAnchor().empty()) {
58 s <<
", trust anchor " << ctx->getTrustAnchor()
59 <<
", cert file " << ctx->getCertFile()
60 <<
", key file " << ctx->getKeyFile();
61 if (ctx->getCertRequired()) {
62 s <<
", client certs are required";
64 s <<
", client certs are optional";
67 s <<
", control sockets: ";
70 s << ctx->getControlSocketInfoSummary();
74 if (auth && !auth->empty()) {
75 s <<
", requires basic HTTP authentication";
80 s <<
", " << libs.size() <<
" lib(s):";
81 for (
auto const& lib : libs) {
82 s << lib.first <<
" ";
103 ElementPtr cfg = boost::const_pointer_cast<Element>(config_set);
113 parser.
parse(ctx, cfg, check_only);
118 excuse =
"undefined configuration parsing error";
134 "Configuration check successful");
137 "Configuration applied successfully.");
143std::list<std::list<std::string>>
145 static std::list<std::list<std::string>>
const list({
146 {
"authentication",
"clients",
"[]"},
147 {
"hooks-libraries",
"[]",
"parameters",
"*"},
154 auto si = ctrl_sockets_.find(service);
160 const std::string& service) {
161 ctrl_sockets_[service] = control_socket;
166 std::ostringstream s;
167 for (
auto const& si : ctrl_sockets_) {
168 if (s.tellp() != 0) {
174 if (s.tellp() == 0) {
189 ca->set(
"http-port",
Element::create(
static_cast<int64_t
>(http_port_)));
191 if (!http_headers_.empty()) {
192 ca->set(
"http-headers", CfgHttpHeaderstoElement(http_headers_));
195 if (!trust_anchor_.empty()) {
203 ca->set(
"authentication", auth_config_->toElement());
205 ca->set(
"hooks-libraries", hooks_config_.
toElement());
208 for (
auto const& si : ctrl_sockets_) {
210 control_sockets->set(si.first, socket);
212 ca->set(
"control-sockets", control_sockets);
215 result->set(
"Control-agent", ca);
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
void checkTlsSetup(const isc::data::ConstElementPtr &config)
Check TLS setup consistency i.e.
void parse(const CtrlAgentCfgContextPtr &ctx, const isc::data::ConstElementPtr &config, bool check_only)
Parses the control agent configuration.
static size_t setAllDefaults(const isc::data::ElementPtr &global)
Sets all defaults for Control Agent configuration.
Control Agent Configuration Context.
void setControlSocketInfo(const isc::data::ConstElementPtr &control_socket, const std::string &service)
Sets information about the control socket.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
CtrlAgentCfgContext()
Default constructor.
isc::data::ConstElementPtr getControlSocketInfo(const std::string &service) const
Returns information about control socket.
std::string getControlSocketInfoSummary() const
Returns socket configuration summary in a textual format.
std::list< std::list< std::string > > jsonPathsToRedact() const final override
Return a list of all paths that contain passwords or secrets.
CtrlAgentCfgMgr()
Constructor.
virtual process::ConfigPtr createNewContext() override
Creates a new, blank CtrlAgentCfgContext context.
virtual isc::data::ConstElementPtr parse(isc::data::ConstElementPtr config, bool check_only) override
Parses configuration of the Control Agent.
CtrlAgentCfgContextPtr getCtrlAgentCfgContext()
Convenience method that returns the Control Agent configuration context.
virtual std::string getConfigSummary(const uint32_t selection) override
Returns configuration summary in the textual format.
virtual ~CtrlAgentCfgMgr()
Destructor.
static ElementPtr create(const Position &pos=ZERO_POSITION())
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
To be removed. Please use ConfigError instead.
isc::data::ElementPtr toElement() const
Unparse a configuration object.
Base class for all configurations.
virtual isc::data::ElementPtr toElement() const
Converts to Element representation.
This file contains several functions and constants that are used for handling commands and responses ...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
const isc::log::MessageID CTRL_AGENT_CONFIG_CHECK_FAIL
boost::shared_ptr< CtrlAgentCfgContext > CtrlAgentCfgContextPtr
Pointer to a configuration context.
isc::log::Logger agent_logger("ctrl-agent")
Control Agent logger.
const isc::log::MessageID CTRL_AGENT_CONFIG_FAIL
const int CONTROL_RESULT_ERROR
Status code indicating a general failure.
ConstElementPtr createAnswer()
Creates a standard config/command level success answer message (i.e.
const int CONTROL_RESULT_SUCCESS
Status code indicating a successful operation.
boost::shared_ptr< const Element > ConstElementPtr
boost::shared_ptr< Element > ElementPtr
std::vector< HookLibInfo > HookLibsCollection
A storage for information about hook libraries.
boost::shared_ptr< HttpAuthConfig > HttpAuthConfigPtr
Type of shared pointers to HTTP authentication configuration.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.
Defines the logger used by the top-level component of kea-lfc.
void contextToElement(data::ElementPtr map) const
Merge unparse a user_context object.
static data::ElementPtr toElement(data::ConstElementPtr map)
Copy an Element map.