Add +[no]showtruncated to dig

Adds the ability to display the truncated message before retrying
the query over TCP.
This commit is contained in:
Mark Andrews 2025-11-25 16:05:07 +11:00
parent 1c55e76b92
commit 44f12f9e61
4 changed files with 21 additions and 3 deletions

View 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;
}

View 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

View 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);
}

View 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 */