]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
kdig: add quic parameter
authorJan Hák <jan.hak@nic.cz>
Mon, 2 May 2022 12:35:46 +0000 (14:35 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Wed, 22 Jun 2022 08:00:23 +0000 (10:00 +0200)
Knot.files
configure.ac
src/utils/Makefile.inc
src/utils/common/params.h
src/utils/common/quic.c [new file with mode: 0644]
src/utils/common/quic.h [new file with mode: 0644]
src/utils/kdig/kdig_params.c
src/utils/kdig/kdig_params.h

index 788f9dc4cb5a4d0fcd20a15c4eaf6699c0f4fea5..3a3e918214d4c8bd35d012c6dcde7a053f7a5198 100644 (file)
@@ -561,6 +561,8 @@ src/utils/common/netio.c
 src/utils/common/netio.h
 src/utils/common/params.c
 src/utils/common/params.h
+src/utils/common/quic.c
+src/utils/common/quic.h
 src/utils/common/resolv.c
 src/utils/common/resolv.h
 src/utils/common/sign.c
index b659857ce889db9096c3331ce54b48d7038ee140..0dff5a67cb60a4f9004303bcc1b7b7d8fd05c749 100644 (file)
@@ -818,6 +818,7 @@ result_msg_base="  Knot DNS $VERSION
     Fast zone parser:       ${enable_fastparser}
     Utilities with IDN:     ${with_libidn}
     Utilities with DoH:     ${with_libnghttp2}
+    Utilities with DoQ:     ${with_libngtcp2}
     Utilities with Dnstap:  ${enable_dnstap}
     MaxMind DB support:     ${enable_maxminddb}
     Systemd integration:    ${enable_systemd}
index 1f84beb81b5aa044819b6c0ef7a3d1537922c4df..efd11dd32faffe7679dc943a8a48d35e4a402dad 100644 (file)
@@ -34,6 +34,8 @@ libknotus_la_SOURCES = \
        utils/common/netio.h                    \
        utils/common/params.c                   \
        utils/common/params.h                   \
+       utils/common/quic.c                     \
+       utils/common/quic.h                     \
        utils/common/resolv.c                   \
        utils/common/resolv.h                   \
        utils/common/sign.c                     \
index 6c3cc311f07ffd5b5b3246826605687a13e3ace7..f39084bc818276b135d4b7b82d1e7ad9c4fc6a73 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2020 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -28,6 +28,7 @@
 #define DEFAULT_IPV6_NAME      "::1"
 #define DEFAULT_DNS_PORT       "53"
 #define DEFAULT_DNS_HTTPS_PORT "443"
+#define DEFAULT_DNS_QUIC_PORT  "853"
 #define DEFAULT_DNS_TLS_PORT   "853"
 #define DEFAULT_UDP_SIZE       512
 #define DEFAULT_EDNS_SIZE      4096
diff --git a/src/utils/common/quic.c b/src/utils/common/quic.c
new file mode 100644 (file)
index 0000000..0daa01b
--- /dev/null
@@ -0,0 +1,39 @@
+/*  Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include <stddef.h>
+#include "libknot/errcode.h"
+#include "utils/common/quic.h"
+
+int quic_params_copy(quic_params_t *dst, const quic_params_t *src)
+{
+       if (dst == NULL || src == NULL) {
+               return KNOT_EINVAL;
+       }
+
+       dst->enable = src->enable;
+
+       return KNOT_EOK;
+}
+
+void quic_params_clean(quic_params_t *params)
+{
+       if (params == NULL) {
+               return;
+       }
+
+       params->enable = false;
+}
diff --git a/src/utils/common/quic.h b/src/utils/common/quic.h
new file mode 100644 (file)
index 0000000..56aee39
--- /dev/null
@@ -0,0 +1,30 @@
+/*  Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <stdbool.h>
+
+/*! \brief QUIC parameters. */
+typedef struct {
+       /*! Use QUIC indicator. */
+       bool enable;
+} quic_params_t;
+
+int quic_params_copy(quic_params_t *dst, const quic_params_t *src);
+
+void quic_params_clean(quic_params_t *params);
+
index 2cef812bcbf15397e25c2c4e63623a48e7eb83e8..b134c6d3882cd0b91b48ee65fa2fb8b170279e77 100644 (file)
@@ -84,6 +84,8 @@ static const style_t DEFAULT_STYLE_DIG = {
        .show_footer = true
 };
 
+static int opt_padding(const char *arg, void *query);
+
 static int opt_multiline(const char *arg, void *query)
 {
        query_t *q = query;
@@ -929,6 +931,36 @@ static int opt_nohttps_get(const char *arg, void *query)
 #endif
 }
 
+static int opt_quic(const char *arg, void *query)
+{
+#ifdef LIBNGTCP2
+       query_t *q = query;
+
+       q->quic.enable = true;
+
+       opt_tls(arg, query);
+       opt_notcp(arg, query);
+       opt_padding(arg, query);
+
+       return KNOT_EOK;
+#else
+       return KNOT_ENOTSUP;
+#endif //LIBNGTCP2
+}
+
+static int opt_noquic(const char *arg, void *query)
+{
+#ifdef LIBNGTCP2
+       query_t *q = query;
+
+       quic_params_clean(&q->quic);
+
+       return opt_notls(arg, query);
+#else
+       return KNOT_ENOTSUP;
+#endif //LIBNGTCP2
+}
+
 static int opt_nsid(const char *arg, void *query)
 {
        query_t *q = query;
@@ -1441,6 +1473,9 @@ static const param_t kdig_opts2[] = {
        { "https-get",      ARG_NONE,     opt_https_get },
        { "nohttps-get",    ARG_NONE,     opt_nohttps_get },
 
+       { "quic",           ARG_NONE,     opt_quic },
+       { "noquic",         ARG_NONE,     opt_noquic },
+
        { "nsid",           ARG_NONE,     opt_nsid },
        { "nonsid",         ARG_NONE,     opt_nonsid },
 
@@ -1546,6 +1581,7 @@ query_t *query_create(const char *owner, const query_t *conf)
                query->port = strdup(conf->port);
                tls_params_copy(&query->tls, &conf->tls);
                https_params_copy(&query->https, &conf->https);
+               quic_params_copy(&query->quic, &conf->quic);
                if (conf->tsig_key.name != NULL) {
                        int ret = knot_tsig_key_copy(&query->tsig_key,
                                                     &conf->tsig_key);
@@ -1608,6 +1644,7 @@ void query_free(query_t *query)
 
        tls_params_clean(&query->tls);
        https_params_clean(&query->https);
+       quic_params_clean(&query->quic);
 
        // Cleanup signing key.
        knot_tsig_key_deinit(&query->tsig_key);
@@ -1990,6 +2027,8 @@ static void complete_servers(query_t *query, const query_t *conf)
                def_port = conf->port;
        } else if (query->https.enable) {
                def_port = DEFAULT_DNS_HTTPS_PORT;
+       } else if (query->quic.enable) {
+               def_port = DEFAULT_DNS_QUIC_PORT;
        } else if (query->tls.enable) {
                def_port = DEFAULT_DNS_TLS_PORT;
        } else {
@@ -2192,6 +2231,9 @@ static void print_help(void)
               "       +[no]https[=URL]           Use HTTPS protocol. It's also possible to specify\n"
               "                                  URL as [authority][/path] where query will be sent.\n"
               "       +[no]https-get             Use HTTPS protocol with GET method instead of POST.\n"
+#endif
+#ifdef LIBNGTCP2
+              "       +[no]quic                  Use QUIC protocol.\n"
 #endif
               "       +[no]nsid                  Request NSID.\n"
               "       +[no]bufsize=B             Set EDNS buffer size.\n"
index fcc28a5a95d402badcda5a4a01ea8775374c3a44..d7b816315f3e8052b404996ed4873c53c842f62f 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
 #include "utils/common/params.h"
 #include "utils/common/exec.h"
 #include "utils/common/https.h"
+#include "utils/common/quic.h"
 #include "utils/common/sign.h"
 #include "libknot/libknot.h"
 #include "contrib/sockaddr.h"
@@ -125,6 +126,8 @@ struct query {
        tls_params_t    tls;
        /*!< HTTPS parameters. */
        https_params_t  https;
+       /*!< QUIC parameters. */
+       quic_params_t   quic;
        /*!< Transaction signature. */
        knot_tsig_key_t tsig_key;
        /*!< EDNS client subnet. */