]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2011] Checkpoint: updated examples
authorFrancis Dupont <fdupont@isc.org>
Mon, 16 Aug 2021 11:39:09 +0000 (13:39 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 2 Sep 2021 15:35:48 +0000 (17:35 +0200)
doc/Makefile.am
doc/examples/ddns/all-keys-netconf.json [new file with mode: 0644]
doc/examples/ddns/all-keys.json [new file with mode: 0644]
src/bin/d2/tests/parser_unittest.cc
src/lib/d2srv/d2_simple_parser.cc

index 2a4b872c415e12bfa5941f3e7225b6f70970e8e2..03f492b52e56f90b393aa86210f572f7639b1599 100644 (file)
@@ -5,6 +5,8 @@ EXTRA_DIST = images/kea-logo-100x70.png
 nobase_dist_doc_DATA  = examples/agent/comments.json
 nobase_dist_doc_DATA += examples/agent/https.json
 nobase_dist_doc_DATA += examples/agent/simple.json
+nobase_dist_doc_DATA += examples/ddns/all-keys.json
+nobase_dist_doc_DATA += examples/ddns/all-keys-netconf.json
 nobase_dist_doc_DATA += examples/ddns/comments.json
 nobase_dist_doc_DATA += examples/ddns/gss-tsig.json
 nobase_dist_doc_DATA += examples/ddns/sample1.json
diff --git a/doc/examples/ddns/all-keys-netconf.json b/doc/examples/ddns/all-keys-netconf.json
new file mode 100644 (file)
index 0000000..765a20f
--- /dev/null
@@ -0,0 +1,174 @@
+// WARNING: This example configuration is not meant for production use.
+// The Kea Kea's DHCP-DDNS server can refuse this configuration because
+// it may contain mutually exclusive configuration parameters.
+//
+// The primary purpose of the example file is to provide a comprehensive
+// list of parameters supported by Kea DHCP-DDNS server along with the
+// brief description of each parameter.
+//
+// This stable version is used for YANG as we do not want to update code
+// and models each time a keyword is added to the syntax.
+{
+    // Kea DHCP-DDNS server configuration begins here.
+    "DhcpDdns": {
+
+    // Global Parameters
+
+    // IP address D2 will listen for update requests at.
+    // Default is 127.0.0.1
+    "ip-address": "127.0.0.1",
+
+    // Port D2 will listen for update requests on.
+    // Default is 53001.
+    "port": 53001,
+
+    // Maximum time to we will wait for a DNS server to respond to us.
+    // Unit is the millisecond, default is 100ms.
+    "dns-server-timeout" : 100,
+
+    // Protocol to use for Name Change Requests from a Kea DHCP server.
+    // Currently only 'UDP' is supported.
+    "ncr-protocol": "UDP",
+
+    // Format to use for Name Change Requests from a Kea DHCP server.
+    // Currently only 'JSON' is supported.
+    "ncr-format": "JSON",
+
+    // Command control socket configuration parameters for Kea DHCP-DDNS server.
+    "control-socket": {
+
+        // Location of the unix domain socket file the DHCP-DDNS server uses
+        // to receive control commands from the Kea Control Agent or the
+        // local server administrator.
+        "socket-name": "/tmp/kea-ddns-ctrl-socket",
+
+        // Control socket type used by the Kea DHCP-DDNS server.
+        // The 'unix' socket is currently the only supported type.
+        "socket-type": "unix"
+    },
+
+    // List of hooks libraries and their specific configuration parameters
+    // to be loaded by Kea DHCP-DDNS server.
+    "hooks-libraries": [
+        {
+            // Location of the hooks library to be loaded.
+            "library": "/opt/local/ddns-server-commands.so",
+
+            // Hook library specific configuration parameters.
+            "parameters": { }
+        }
+    ],
+
+    // Forward DDNS (Dynamic DNS).
+    "forward-ddns": {
+
+        // List of DDNS domains.
+        "ddns-domains": [
+            {
+                // Name of the zone (required).
+                "name": "example.com.",
+
+                // Name of the TSIG key used to protect DNS updates.
+                "key-name": "d2.md5.key",
+
+                // List of DNS servers where to send DNS updates.
+                "dns-servers": [
+                    {
+                        // DNS server IP address (required).
+                        "ip-address": "2001:db8:1::10",
+
+                        // DNS server UDP port. Default is 53 (DNS service).
+                        "port": 7802
+                    }
+                ]
+            }
+        ]
+    },
+
+    // Reverse DDNS (Dynamic DNS).
+    "reverse-ddns": {
+
+        // List of DDNS domains.
+        "ddns-domains": [
+            {
+                // Name of the zone (required).
+                "name": "2.0.192.in-addr.arpa.",
+
+                // Name of the TSIG key used to protect DNS updates.
+                "key-name": "d2.sha1.key",
+
+                // List of DNS servers where to send DNS updates.
+                "dns-servers": [
+                    {
+                        // DNS server IP address (required).
+                        "ip-address": "172.16.1.1",
+
+                        // DNS server UDP port. Default is 53 (DNS service).
+                        "port": 5301
+                    }
+                ]
+            }
+        ]
+    },
+
+    // List of TSIG keys used to protect DNS updates.
+    "tsig-keys": [
+        {
+            // Name of the TSIG key (required).
+            "name": "d2.md5.key",
+
+            // Algorithm of the TSIG key (required).
+            // The value must be a valid algorithm name e.g.
+            // HMAC-MD5, HMAC-SHA1, HMAC-SHA224, ...
+            "algorithm": "HMAC-MD5",
+
+            // Number of bits in the digest. Default is 0 which means
+            // to use all bits provided by the algorithm. Too short values
+            // (depending on the algorithm) are rejected.
+            "digest-bits": 0,
+
+            // Secret of the TSIG key (required) in base-64.
+            "secret": "LSWXnfkKZjdPJI5QxlpnfQ=="
+        }
+    ],
+
+    // List of loggers used by the servers using this configuration file.
+    "loggers": [
+        {
+            // Debug level, a value between 0..99. The greater the value
+            // the more detailed debug log.
+            "debuglevel": 99,
+
+            // Name of the logger.
+            "name": "kea-dhcp-ddns",
+
+            // Configures how the log should be output.
+            "output_options": [
+                {
+                    // Determines whether the log should flushed to a file.
+                    "flush": true,
+
+                    // Specifies maximum filesize before the file is being rotated.
+                    "maxsize": 10240000,
+
+                    // Specifies the maximum number of rotated files being kept.
+                    "maxver": 1,
+
+                    // Specifies logging destination.
+                    "output": "stdout",
+
+                    // Specifies log entry content
+                    "pattern": "%D{%Y-%m-%d %H:%M:%S.%q} %-5p [%c/%i] %m\n"
+                }
+            ],
+
+            // Specifies logging severity, i.e. "ERROR", "WARN", "INFO", "DEBUG".
+            "severity": "INFO"
+        }
+    ],
+
+    // Look at sample1 example for the use of user-contexts.
+    "user-context": { }
+}
+
+}
diff --git a/doc/examples/ddns/all-keys.json b/doc/examples/ddns/all-keys.json
new file mode 100644 (file)
index 0000000..7de1703
--- /dev/null
@@ -0,0 +1,183 @@
+// WARNING: This example configuration is not meant for production use.
+// The Kea Kea's DHCP-DDNS server can refuse this configuration because
+// it may contain mutually exclusive configuration parameters.
+//
+// The primary purpose of the example file is to provide a comprehensive
+// list of parameters supported by Kea DHCP-DDNS server along with the
+// brief description of each parameter.
+//
+// This current version should be up to date, i.e. new keywords should be
+// added in this file at the same time than in the syntax.
+{
+    // Kea DHCP-DDNS server configuration begins here.
+    "DhcpDdns": {
+
+    // Global Parameters
+
+    // IP address D2 will listen for update requests at.
+    // Default is 127.0.0.1
+    "ip-address": "127.0.0.1",
+
+    // Port D2 will listen for update requests on.
+    // Default is 53001.
+    "port": 53001,
+
+    // Maximum time to we will wait for a DNS server to respond to us.
+    // Unit is the millisecond, default is 100ms.
+    "dns-server-timeout" : 100,
+
+    // Protocol to use for Name Change Requests from a Kea DHCP server.
+    // Currently only 'UDP' is supported.
+    "ncr-protocol": "UDP",
+
+    // Format to use for Name Change Requests from a Kea DHCP server.
+    // Currently only 'JSON' is supported.
+    "ncr-format": "JSON",
+
+    // Command control socket configuration parameters for Kea DHCP-DDNS server.
+    "control-socket": {
+
+        // Location of the unix domain socket file the DHCP-DDNS server uses
+        // to receive control commands from the Kea Control Agent or the
+        // local server administrator.
+        "socket-name": "/tmp/kea-ddns-ctrl-socket",
+
+        // Control socket type used by the Kea DHCP-DDNS server.
+        // The 'unix' socket is currently the only supported type.
+        "socket-type": "unix"
+    },
+
+    // List of hooks libraries and their specific configuration parameters
+    // to be loaded by Kea DHCP-DDNS server.
+    "hooks-libraries": [
+        {
+            // Location of the hooks library to be loaded.
+            "library": "/opt/local/ddns-server-commands.so",
+
+            // Hook library specific configuration parameters.
+            "parameters": { }
+        }
+    ],
+
+    // Forward DDNS (Dynamic DNS).
+    "forward-ddns": {
+
+        // List of DDNS domains.
+        "ddns-domains": [
+            {
+                // Name of the zone (required).
+                "name": "example.com.",
+
+                // Name of the TSIG key used to protect DNS updates for
+                // names in the domain.
+                "key-name": "d2.md5.key",
+
+                // List of DNS servers where to send DNS updates.
+                "dns-servers": [
+                    {
+                        // DNS server IP address (required).
+                        "ip-address": "2001:db8:1::10",
+
+                        // DNS server UDP port. Default is 53 (DNS service).
+                        "port": 7802,
+
+                        // Name of the TSIG key used to protect DNS updates
+                        // sent to the DNS server.
+                        "key-name": "d2.sha1.key"
+                    }
+                ]
+            }
+        ]
+    },
+
+    // Reverse DDNS (Dynamic DNS).
+    "reverse-ddns": {
+
+        // List of DDNS domains.
+        "ddns-domains": [
+            {
+                // Name of the zone (required).
+                "name": "2.0.192.in-addr.arpa.",
+
+                // Name of the TSIG key used to protect DNS updates for
+                // names in the domain.
+                "key-name": "d2.sha1.key",
+
+                // List of DNS servers where to send DNS updates.
+                "dns-servers": [
+                    {
+                        // DNS server IP address (required).
+                        "ip-address": "172.16.1.1",
+
+                        // DNS server UDP port. Default is 53 (DNS service).
+                        "port": 5301,
+
+                        // Name of the TSIG key used to protect DNS updates
+                        "key-name": "d2.md5.key"
+                    }
+                ]
+            }
+        ]
+    },
+
+    // List of TSIG keys used to protect DNS updates.
+    "tsig-keys": [
+        {
+            // Name of the TSIG key (required).
+            "name": "d2.md5.key",
+
+            // Algorithm of the TSIG key (required).
+            // The value must be a valid algorithm name e.g.
+            // HMAC-MD5, HMAC-SHA1, HMAC-SHA224, ...
+            "algorithm": "HMAC-MD5",
+
+            // Number of bits in the digest. Default is 0 which means
+            // to use all bits provided by the algorithm. Too short values
+            // (depending on the algorithm) are rejected.
+            "digest-bits": 0,
+
+            // Secret of the TSIG key (required) in base-64.
+            "secret": "LSWXnfkKZjdPJI5QxlpnfQ=="
+        }
+    ],
+
+    // List of loggers used by the servers using this configuration file.
+    "loggers": [
+        {
+            // Debug level, a value between 0..99. The greater the value
+            // the more detailed debug log.
+            "debuglevel": 99,
+
+            // Name of the logger.
+            "name": "kea-dhcp-ddns",
+
+            // Configures how the log should be output.
+            "output_options": [
+                {
+                    // Determines whether the log should flushed to a file.
+                    "flush": true,
+
+                    // Specifies maximum filesize before the file is being rotated.
+                    "maxsize": 10240000,
+
+                    // Specifies the maximum number of rotated files being kept.
+                    "maxver": 1,
+
+                    // Specifies logging destination.
+                    "output": "stdout",
+
+                    // Specifies log entry content
+                    "pattern": "%D{%Y-%m-%d %H:%M:%S.%q} %-5p [%c/%i] %m\n"
+                }
+            ],
+
+            // Specifies logging severity, i.e. "ERROR", "WARN", "INFO", "DEBUG".
+            "severity": "INFO"
+        }
+    ],
+
+    // Look at sample1 example for the use of user-contexts.
+    "user-context": { }
+}
+
+}
index 53220130e74670130f917da632198686f98ed505..ff3a6b4d125d2bed9c5545b938fe7a246681f4f0 100644 (file)
@@ -246,7 +246,7 @@ void testFile(const std::string& fname) {
 
     cout << "Parsing file " << fname << " (" << decommented << ")" << endl;
 
-    EXPECT_NO_THROW(json = Element::fromJSONFile(decommented, true));
+    ASSERT_NO_THROW(json = Element::fromJSONFile(decommented, true));
     reference_json = moveComments(json);
 
     // remove the temporary file
@@ -272,6 +272,8 @@ void testFile(const std::string& fname) {
 // the second time with D2Parser. Both JSON trees are then compared.
 TEST(ParserTest, file) {
     vector<string> configs;
+    configs.push_back("all-keys.json");
+    configs.push_back("all-keys-netconf.json");
     configs.push_back("comments.json");
     configs.push_back("gss-tsig.json");
     configs.push_back("sample1.json");
@@ -701,12 +703,15 @@ TEST(ParserTest, mapEntries) {
     }
     syntax_file.close();
 
-    // Get keywords from the sample file
-    string sample_dir(D2_TEST_DATA_DIR);
+    // Get keywords from the exsample files
+    string sample_dir(CFG_EXAMPLES);
     sample_dir += "/";
     ElementPtr sample_json = Element::createList();
-    loadFile(sample_dir + "get_config.json", sample_json);
-    KeywordSet sample_keys;
+    loadFile(sample_dir + "all-keys.json", sample_json);
+    loadFile(sample_dir + "all-keys-netconf.json", sample_json);
+    KeywordSet sample_keys = {
+        "hostname"
+    };
     // Recursively extract keywords.
     static void (*extract)(ConstElementPtr, KeywordSet&) =
         [] (ConstElementPtr json, KeywordSet& set) {
@@ -755,8 +760,8 @@ void testDuplicate(ConstElementPtr json) {
 // This test checks that duplicate entries make parsing to fail.
 TEST(ParserTest, duplicateMapEntries) {
     // Get the config to work with from the sample file.
-    string sample_fname(D2_TEST_DATA_DIR);
-    sample_fname += "/get_config.json";
+    string sample_fname(CFG_EXAMPLES);
+    sample_fname += "/all-keys.json";
     D2ParserContext ctx;
     ElementPtr sample_json;
     EXPECT_NO_THROW(sample_json =
index e6e8594551dba51771a9de619ff1ec7e7f189981..81bab9c0cef512e9e5736700876124a102782b97 100644 (file)
@@ -82,7 +82,7 @@ namespace d2 {
 const SimpleDefaults D2SimpleParser::D2_GLOBAL_DEFAULTS = {
     { "ip-address",         Element::string, "127.0.0.1" },
     { "port",               Element::integer, "53001" },
-    { "dns-server-timeout", Element::integer, "100" }, // in seconds
+    { "dns-server-timeout", Element::integer, "100" }, // in milliseconds
     { "ncr-protocol",       Element::string, "UDP" },
     { "ncr-format",         Element::string, "JSON" }
 };