15#include <boost/range/adaptor/reversed.hpp>
30typedef std::vector<uint8_t> ByteAddress;
46 d2_params_ = rhs.d2_params_;
47 if (rhs.forward_mgr_) {
48 forward_mgr_.reset(new DdnsDomainListMgr(rhs.forward_mgr_->getName()));
49 forward_mgr_->setDomains(rhs.forward_mgr_->getDomains());
52 if (rhs.reverse_mgr_) {
53 reverse_mgr_.reset(new DdnsDomainListMgr(rhs.reverse_mgr_->getName()));
54 reverse_mgr_->setDomains(rhs.reverse_mgr_->getDomains());
59 unix_control_socket_ = rhs.unix_control_socket_;
61 http_control_socket_ = rhs.http_control_socket_;
63 hooks_config_ = rhs.hooks_config_;
75 const IOAddress& ip_address = d2_params_->getIpAddress();
78 size_t port = d2_params_->getPort();
81 size_t dns_server_timeout = d2_params_->getDnsServerTimeout();
82 d2->set(
"dns-server-timeout",
86 d2_params_->getNcrProtocol();
87 d2->set(
"ncr-protocol",
95 forward_ddns->set(
"ddns-domains", forward_mgr_->toElement());
96 d2->set(
"forward-ddns", forward_ddns);
99 reverse_ddns->set(
"ddns-domains", reverse_mgr_->toElement());
100 d2->set(
"reverse-ddns", reverse_ddns);
103 for (
auto const& key : *keys_) {
104 tsig_keys->add(key.second->toElement());
106 d2->set(
"tsig-keys", tsig_keys);
109 if (!
isNull(unix_control_socket_)) {
110 for (
auto const& socket : unix_control_socket_->listValue()) {
114 if (!
isNull(http_control_socket_)) {
115 for (
auto const& socket : http_control_socket_->listValue()) {
119 if (!control_sockets->empty()) {
120 d2->set(
"control-sockets", control_sockets);
123 d2->set(
"hooks-libraries", hooks_config_.toElement());
126 result->set(
"DhcpDdns",
d2);
167 return (mgr->matchDomain(fqdn, domain));
172 const std::string& reverse_zone ) {
179 return (mgr->matchDomain(reverse_address, domain));
184 const std::string& reverse_zone ) {
197 << address <<
" : " << ex.
what());
203 if (!ioaddr.
isV4()) {
209 const ByteAddress bytes = ioaddr.
toBytes();
212 std::ostringstream stream;
214 for (
auto const& rit : boost::adaptors::reverse(bytes)) {
215 stream << static_cast<unsigned int>(rit) <<
".";
219 if (reverse_zone.empty()) {
222 stream << reverse_zone;
223 if (reverse_zone.back() !=
'.') {
228 return(stream.str());
233 if (!ioaddr.
isV6()) {
238 const ByteAddress bytes = ioaddr.
toBytes();
242 std::ostringstream stream;
244 for (
auto const& rit : boost::adaptors::reverse(digits)) {
245 stream << static_cast<char>(rit) <<
".";
249 if (reverse_zone.empty()) {
252 stream << reverse_zone;
253 if (reverse_zone.back() !=
'.') {
258 return(stream.str());
296 ElementPtr cfg = boost::const_pointer_cast<Element>(config_set);
305 parser.
parse(ctx, cfg, check_only);
310 excuse =
"undefined configuration parsing error";
326 "Configuration check successful");
336 "Configuration applied successfully.", params);
342std::list<std::list<std::string>>
344 static std::list<std::list<std::string>>
const list({
346 {
"hooks-libraries",
"[]",
"parameters",
"*"},
static ElementPtr create(const Position &pos=ZERO_POSITION())
Create a NullElement.
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.
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.
static std::string reverseV4Address(const isc::asiolink::IOAddress &ioaddr, const std::string &reverse_zone)
Generate a reverse order string for the given IP address.
virtual ~D2CfgMgr()
Destructor.
static std::string reverseV6Address(const isc::asiolink::IOAddress &ioaddr, const std::string &reverse_zone)
Generate a reverse order string for the given IP address.
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.
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.
bool matchReverse(const std::string &ip_address, DdnsDomainPtr &domain, const std::string &reverse_zone="")
Matches a given IP address to a reverse domain.
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.
bool forwardUpdatesEnabled()
Returns whether or not forward updates are enabled.
virtual std::string getConfigSummary(const uint32_t selection) override
Returns configuration summary in the textual format.
static std::string reverseIpAddress(const std::string &address, const std::string &reverse_zone="")
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.
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.
Base class for all configurations.
virtual isc::data::ElementPtr toElement() const
Converts to Element representation.
DCfgMgrBase(ConfigPtr context)
Constructor.
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.
const std::string DDNS_REV_ZONE_DEFAULT6
Default reverse DNS domain for V6.
boost::shared_ptr< DdnsDomain > DdnsDomainPtr
Defines a pointer for DdnsDomain instances.
const isc::log::MessageID DHCP_DDNS_CONFIG_CHECK_FAIL
const std::string DDNS_REV_ZONE_DEFAULT4
Default reverse DNS domain for V4.
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
NameChangeProtocol
Defines the list of socket protocols supported.
NameChangeFormat
Defines the list of data wire formats 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.