From: Mark Andrews Date: Tue, 25 Nov 2025 05:05:07 +0000 (+1100) Subject: Add +[no]showtruncated to dig X-Git-Tag: v9.21.16~7^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44f12f9e6102484a471c7cffa42242185652e307;p=thirdparty%2Fbind9.git Add +[no]showtruncated to dig Adds the ability to display the truncated message before retrying the query over TCP. --- diff --git a/bin/dig/dig.c b/bin/dig/dig.c index a1297a5396f..f227f4e99ac 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -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; } diff --git a/bin/dig/dig.rst b/bin/dig/dig.rst index a99b6b873ed..99e7d096b93 100644 --- a/bin/dig/dig.rst +++ b/bin/dig/dig.rst @@ -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 diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 5045ef6cb7b..30895c8103e 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -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); } diff --git a/bin/dig/dighost.h b/bin/dig/dighost.h index 56880eab396..470429bcba6 100644 --- a/bin/dig/dighost.h +++ b/bin/dig/dighost.h @@ -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 */