15#include <boost/range/adaptor/reversed.hpp>
27typedef std::vector<uint8_t> ByteAddress;
43 d2_params_ = rhs.d2_params_;
44 if (rhs.forward_mgr_) {
45 forward_mgr_.reset(new DdnsDomainListMgr(rhs.forward_mgr_->getName()));
46 forward_mgr_->setDomains(rhs.forward_mgr_->getDomains());
49 if (rhs.reverse_mgr_) {
50 reverse_mgr_.reset(new DdnsDomainListMgr(rhs.reverse_mgr_->getName()));
51 reverse_mgr_->setDomains(rhs.reverse_mgr_->getDomains());
56 unix_control_socket_ = rhs.unix_control_socket_;
58 http_control_socket_ = rhs.http_control_socket_;
60 hooks_config_ = rhs.hooks_config_;
72 const IOAddress& ip_address = d2_params_->getIpAddress();
75 size_t port = d2_params_->getPort();
78 size_t dns_server_timeout = d2_params_->getDnsServerTimeout();
79 d2->set(
"dns-server-timeout",
83 d2_params_->getNcrProtocol();
84 d2->set(
"ncr-protocol",
92 forward_ddns->set(
"ddns-domains", forward_mgr_->toElement());
93 d2->set(
"forward-ddns", forward_ddns);
96 reverse_ddns->set(
"ddns-domains", reverse_mgr_->toElement());
97 d2->set(
"reverse-ddns", reverse_ddns);
100 for (
auto const& key : *keys_) {
101 tsig_keys->add(key.second->toElement());
103 d2->set(
"tsig-keys", tsig_keys);
106 if (!
isNull(unix_control_socket_)) {
107 for (
auto const& socket : unix_control_socket_->listValue()) {
111 if (!
isNull(http_control_socket_)) {
112 for (
auto const& socket : http_control_socket_->listValue()) {
116 if (!control_sockets->empty()) {
117 d2->set(
"control-sockets", control_sockets);
120 d2->set(
"hooks-libraries", hooks_config_.
toElement());
123 result->set(
"DhcpDdns", d2);
168 return (mgr->matchDomain(fqdn, domain));
179 return (mgr->matchDomain(reverse_address, domain));
196 << address <<
" : " << ex.
what());
202 if (!ioaddr.
isV4()) {
208 const ByteAddress bytes = ioaddr.
toBytes();
211 std::ostringstream stream;
213 for (
auto const& rit : boost::adaptors::reverse(bytes)) {
214 stream << static_cast<unsigned int>(rit) <<
".";
219 return(stream.str());
224 if (!ioaddr.
isV6()) {
229 const ByteAddress bytes = ioaddr.
toBytes();
233 std::ostringstream stream;
235 for (
auto const& rit : boost::adaptors::reverse(digits)) {
236 stream << static_cast<char>(rit) <<
".";
241 return(stream.str());
279 ElementPtr cfg = boost::const_pointer_cast<Element>(config_set);
288 parser.
parse(ctx, cfg, check_only);
293 excuse =
"undefined configuration parsing error";
309 "Configuration check successful");
319 "Configuration applied successfully.", params);
325std::list<std::list<std::string>>
327 static std::list<std::list<std::string>>
const list({
329 {
"hooks-libraries",
"[]",
"parameters",
"*"},
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.
The IOAddress class represents an IP addresses (version agnostic)
std::string toText() const
Convert the address to a string.
bool isV6() const
Convenience function to check for an IPv6 address.
bool isV4() const
Convenience function to check for an IPv4 address.
std::vector< uint8_t > toBytes() const
Return address as set of bytes.
static std::string getHash(const isc::data::ConstElementPtr &config)
returns a hash of a given Element structure
DHCP-DDNS Configuration Context.
virtual ~D2CfgContext()
Destructor.
virtual isc::data::ElementPtr toElement() const
Unparse a configuration object.
D2CfgContext()
Constructor.
Exception thrown when the error during configuration handling occurs.
virtual ~D2CfgMgr()
Destructor.
bool matchForward(const std::string &fqdn, DdnsDomainPtr &domain)
Matches a given FQDN to a forward domain.
const isc::data::ConstElementPtr getHttpControlSocketInfo()
Convenience method fetches information about HTTP/HTTPS control socket from context.
virtual process::ConfigPtr createNewContext() override
Creates an new, blank D2CfgContext context.
static std::string reverseIpAddress(const std::string &address)
Generate a reverse order string for the given IP address.
const isc::data::ConstElementPtr getUnixControlSocketInfo()
Convenience method fetches information about UNIX control socket from context.
D2CfgContextPtr getD2CfgContext()
Convenience method that returns the D2 configuration context.
bool reverseUpdatesEnabled()
Returns whether or not reverse updates are enabled.
virtual void setCfgDefaults(isc::data::ElementPtr mutable_config) override
Adds default values to the given config.
std::list< std::list< std::string > > jsonPathsToRedact() const final override
Return a list of all paths that contain passwords or secrets.
static const char * IPV6_REV_ZONE_SUFFIX
Reverse zone suffix added to IPv6 addresses for reverse lookups.
static std::string reverseV4Address(const isc::asiolink::IOAddress &ioaddr)
Generate a reverse order string for the given IP address.
bool forwardUpdatesEnabled()
Returns whether or not forward updates are enabled.
bool matchReverse(const std::string &ip_address, DdnsDomainPtr &domain)
Matches a given IP address to a reverse domain.
virtual std::string getConfigSummary(const uint32_t selection) override
Returns configuration summary in the textual format.
static std::string reverseV6Address(const isc::asiolink::IOAddress &ioaddr)
Generate a reverse order string for the given IP address.
const D2ParamsPtr & getD2Params()
Convenience method fetches the D2Params from context.
virtual isc::data::ConstElementPtr parse(isc::data::ConstElementPtr config, bool check_only) override
Parses configuration of the D2.
static const char * IPV4_REV_ZONE_SUFFIX
Reverse zone suffix added to IPv4 addresses for reverse lookups.
Acts as a storage vault for D2 global scalar parameters.
void parse(const D2CfgContextPtr &ctx, const isc::data::ConstElementPtr &config, bool check_only)
Parses the whole D2 configuration.
static size_t setAllDefaults(data::ElementPtr global)
Sets all defaults for D2 configuration.
Provides storage for and management of a list of DNS domains.
static ElementPtr create(const Position &pos=ZERO_POSITION())
static ElementPtr createMap(const Position &pos=ZERO_POSITION())
Creates an empty MapElement type ElementPtr.
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
isc::data::ElementPtr toElement() const
Unparse a configuration object.
Base class for all configurations.
virtual isc::data::ElementPtr toElement() const
Converts to Element representation.
ConfigPtr & getContext()
Fetches the configuration context.
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 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< DdnsDomainListMgr > DdnsDomainListMgrPtr
Defines a pointer for DdnsDomain instances.
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
const isc::log::MessageID DHCP_DDNS_CONFIG_CHECK_FAIL
std::map< std::string, TSIGKeyInfoPtr > TSIGKeyInfoMap
Defines a map of TSIGKeyInfos, keyed by the name.
boost::shared_ptr< D2CfgContext > D2CfgContextPtr
Pointer to a configuration context.
isc::log::Logger d2_logger("dhcpddns")
Defines the logger used within D2.
boost::shared_ptr< D2Params > D2ParamsPtr
Defines a pointer for D2Params instances.
const isc::log::MessageID DHCP_DDNS_CONFIG_FAIL
boost::shared_ptr< const Element > ConstElementPtr
bool isNull(ConstElementPtr p)
Checks whether the given ElementPtr is a NULL pointer.
boost::shared_ptr< Element > ElementPtr
NameChangeFormat
Defines the list of data wire formats supported.
NameChangeProtocol
Defines the list of socket protocols supported.
std::string ncrProtocolToString(NameChangeProtocol protocol)
Function which converts NameChangeProtocol enums to text labels.
std::string ncrFormatToString(NameChangeFormat format)
Function which converts NameChangeFormat enums to text labels.
boost::shared_ptr< ConfigBase > ConfigPtr
Non-const pointer to the ConfigBase.
string encodeHex(const vector< uint8_t > &binary)
Encode binary data in the base16 format.
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.