]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add +[no]showtruncated to dig
authorMark Andrews <marka@isc.org>
Tue, 25 Nov 2025 05:05:07 +0000 (16:05 +1100)
committerMark Andrews <marka@isc.org>
Mon, 1 Dec 2025 22:34:13 +0000 (09:34 +1100)
Adds the ability to display the truncated message before retrying
the query over TCP.

bin/dig/dig.c
bin/dig/dig.rst
bin/dig/dighost.c
bin/dig/dighost.h

index a1297a5396fec4aee7a42b1ef0a990e9cfc9b3f2..f227f4e99acdd2bb94b4fa1c5b406fe04856ab17 100644 (file)
@@ -306,6 +306,7 @@ help(void) {
               "                 +[no]showbadvers    (Show BADVERS message)\n"
               "                 +[no]showsearch     (Search with intermediate "
               "results)\n"
+              "                 +[no]showtruncated  (Show truncated message)\n"
               "                 +[no]split=##       (Split hex/base64 fields "
               "into chunks)\n"
               "                 +[no]stats          (Control display of "
@@ -2333,6 +2334,10 @@ plus_option(char *option, bool is_batchfile, bool *need_clone,
                                                usesearch = state;
                                        }
                                        break;
+                               case 't':
+                                       FULLCHECK("showtruncated");
+                                       lookup->showtruncated = state;
+                                       break;
                                default:
                                        goto invalid_option;
                                }
index a99b6b873ed2410c4f58ccfaf4389011ec9807b6..99e7d096b9351a153f1c004ae8fb480668a07d87 100644 (file)
@@ -631,6 +631,12 @@ abbreviation is unambiguous; for example, :option:`+cd` is equivalent to
 
    This option performs [or does not perform] a search showing intermediate results.
 
+.. option:: +showtruncated, +noshowtruncated
+
+   This option toggles whether to show the truncated message before
+   retrying the request over TCP or not. The default is to not show
+   the messages.
+
 .. option:: +split=W
 
    This option splits long hex- or base64-formatted fields in resource records into
index 5045ef6cb7b412e12d523bcb16ffc5e959f6c981..30895c8103ecf7d02350d049ce1b570bbbb2a592 100644 (file)
@@ -727,6 +727,7 @@ clone_lookup(dig_lookup_t *lookold, bool servers) {
 
        looknew->showbadcookie = lookold->showbadcookie;
        looknew->showbadvers = lookold->showbadvers;
+       looknew->showtruncated = lookold->showtruncated;
        looknew->sendcookie = lookold->sendcookie;
        looknew->seenbadcookie = lookold->seenbadcookie;
        looknew->badcookie = lookold->badcookie;
@@ -4261,6 +4262,11 @@ recv_done(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region,
        if ((msg->flags & DNS_MESSAGEFLAG_TC) != 0 && !l->ignore &&
            !l->tcp_mode)
        {
+               if (l->showtruncated) {
+                       dighost_printmessage(query, &b, msg, true);
+                       dighost_received(isc_buffer_usedlength(&b), &peer,
+                                        query);
+               }
                if (l->cookie == NULL && l->sendcookie && msg->opt != NULL) {
                        process_opt(l, msg);
                }
index 56880eab396f71f34fc5037ee3df2040956b2f14..470429bcba638dfd03e69c1db0e721a70e67f45d 100644 (file)
@@ -118,9 +118,10 @@ struct dig_lookup {
                section_answer, section_authority, section_question,
                seenbadcookie, sendcookie, servfail_stops,
                setqid, /*% use a speciied query ID */
-               showbadcookie, showbadvers, stats, tcflag, tcp_keepalive,
-               tcp_mode, tcp_mode_set, tls_mode, /*% connect using TLS */
-               trace,                            /*% dig +trace */
+               showbadcookie, showbadvers, showtruncated, 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, zoneversion;
        char textname[MXNAME]; /*% Name we're going to be looking up */