Commit 299566e1 authored by Mark Andrews's avatar Mark Andrews
Browse files

Add the ability to display the BADCOOKIE message in dig when

+badcookie is in effect.
parent 90298dfc
Pipeline #58178 failed with stages
in 19 minutes and 19 seconds
......@@ -278,6 +278,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 "
......@@ -1715,10 +1716,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:
......
......@@ -476,6 +476,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.
......
......@@ -641,6 +641,7 @@ make_empty_lookup(void) {
looknew->tcp_keepalive = false;
looknew->padding = 0;
looknew->header_only = false;
looknew->showbadcookie = false;
looknew->sendcookie = false;
looknew->seenbadcookie = false;
looknew->badcookie = true;
......@@ -787,6 +788,7 @@ clone_lookup(dig_lookup_t *lookold, bool servers) {
looknew->nsid = lookold->nsid;
looknew->tcp_keepalive = lookold->tcp_keepalive;
looknew->header_only = lookold->header_only;
looknew->showbadcookie = lookold->showbadcookie;
looknew->sendcookie = lookold->sendcookie;
looknew->seenbadcookie = lookold->seenbadcookie;
looknew->badcookie = lookold->badcookie;
......@@ -3860,9 +3862,15 @@ recv_done(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region,
{
process_opt(l, msg);
if (msg->cc_ok) {
dighost_comments(l, "BADCOOKIE, retrying%s.",
l->seenbadcookie ? " in TCP mode"
: "");
if (l->showbadcookie) {
dighost_printmessage(query, &b, msg, true);
dighost_received(isc_buffer_usedlength(&b),
&peer, query);
} else {
dighost_comments(
l, "BADCOOKIE, retrying%s.",
l->seenbadcookie ? " in TCP mode" : "");
}
n = requeue_lookup(l, true);
if (l->seenbadcookie) {
n->tcp_mode = true;
......
......@@ -116,9 +116,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 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment