]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add the ability to display the BADCOOKIE message in dig when
authorMark Andrews <marka@isc.org>
Tue, 1 Dec 2020 04:10:32 +0000 (15:10 +1100)
committerMark Andrews <marka@isc.org>
Tue, 17 Aug 2021 23:44:50 +0000 (09:44 +1000)
+badcookie is in effect.

bin/dig/dig.c
bin/dig/dig.rst
bin/dig/dighost.c
bin/dig/dighost.h
doc/man/dig.1in

index 7cec01aba1ddc4c3852c4e41f8411851f45bfbef..0dad0153dea86814d40244d73d6de504a32ae8b8 100644 (file)
@@ -282,6 +282,7 @@ help(void) {
               "short\n"
               "                                      form of answers - global "
               "option)\n"
+              "                 +[no]showbadcookie  (Show BADCOOKIE message)\n"
               "                 +[no]showsearch     (Search with intermediate "
               "results)\n"
               "                 +[no]split=##       (Split hex/base64 fields "
@@ -1795,10 +1796,20 @@ plus_option(char *option, bool is_batchfile, bool *need_clone,
                                }
                                break;
                        case 'w': /* showsearch */
-                               FULLCHECK("showsearch");
-                               if (!lookup->trace) {
-                                       showsearch = state;
-                                       usesearch = state;
+                               switch (cmd[4]) {
+                               case 'b':
+                                       FULLCHECK("showbadcookie");
+                                       lookup->showbadcookie = state;
+                                       break;
+                               case 's':
+                                       FULLCHECK("showsearch");
+                                       if (!lookup->trace) {
+                                               showsearch = state;
+                                               usesearch = state;
+                                       }
+                                       break;
+                               default:
+                                       goto invalid_option;
                                }
                                break;
                        default:
index 93c0b26c43ae9c7abe4935fc4c073da59f512539..c447eb879d938a78c6ff19c04162b5a53007fa9b 100644 (file)
@@ -503,6 +503,11 @@ abbreviation is unambiguous; for example, ``+cd`` is equivalent to
    form. This option always has a global effect; it cannot be set globally and
    then overridden on a per-lookup basis.
 
+``+[no]showbadcookie``
+   This option toggles whether to show the message containing the
+   BADCOOKIE rcode before retrying the request or not. The default
+   is to not show the messages.
+
 ``+[no]showsearch``
    This option performs [or does not perform] a search showing intermediate results.
 
index b6131e0831c12423270316c98ba3235c78b61fd4..14859ed74c736317986da3404b5b1b37276c3422 100644 (file)
@@ -735,6 +735,8 @@ clone_lookup(dig_lookup_t *lookold, bool servers) {
        }
        looknew->https_get = lookold->https_get;
        looknew->http_plain = lookold->http_plain;
+
+       looknew->showbadcookie = lookold->showbadcookie;
        looknew->sendcookie = lookold->sendcookie;
        looknew->seenbadcookie = lookold->seenbadcookie;
        looknew->badcookie = lookold->badcookie;
@@ -3852,6 +3854,11 @@ recv_done(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region,
        {
                process_opt(l, msg);
                if (msg->cc_ok) {
+                       if (l->showbadcookie) {
+                               dighost_printmessage(query, &b, msg, true);
+                               dighost_received(isc_buffer_usedlength(&b),
+                                                &peer, query);
+                       }
                        dighost_comments(l, "BADCOOKIE, retrying%s.",
                                         l->seenbadcookie ? " in TCP mode"
                                                          : "");
index 8da437625b80a42dc37d1778a72b7353b81a9d6d..c02e23d67c12c186145f1f1a12205a2165b3bc33 100644 (file)
@@ -120,9 +120,9 @@ struct dig_lookup {
                section_answer, section_authority, section_question,
                seenbadcookie, sendcookie, servfail_stops,
                setqid, /*% use a speciied query ID */
-               stats, tcflag, tcp_keepalive, tcp_mode, tcp_mode_set,
-               tls_mode,   /*% connect using TLS */
-               trace,      /*% dig +trace */
+               showbadcookie, stats, tcflag, tcp_keepalive, tcp_mode,
+               tcp_mode_set, tls_mode, /*% connect using TLS */
+               trace,                  /*% dig +trace */
                trace_root, /*% initial query for either +trace or +nssearch */
                ttlunits, use_usec, waiting_connect, zflag;
        char textname[MXNAME]; /*% Name we're going to be looking up */
index 10d7a4491184cdca1dd1f0d667185e538e8d2872..3d7b332857dd245898308565029b887de7312899 100644 (file)
@@ -515,6 +515,11 @@ This option toggles whether a terse answer is provided. The default is to print
 form. This option always has a global effect; it cannot be set globally and
 then overridden on a per\-lookup basis.
 .TP
+.B \fB+[no]showbadcookie\fP
+This option toggles whether to show the message containing the
+BADCOOKIE rcode before retrying the request or not. The default
+is to not show the messages.
+.TP
 .B \fB+[no]showsearch\fP
 This option performs [or does not perform] a search showing intermediate results.
 .TP