2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-01 06:55:30 +00:00

1915. [func] dig now has a '-q queryname' and '+showsearch' options.

[RT #15034]
This commit is contained in:
Mark Andrews
2005-08-25 00:17:46 +00:00
parent 2c15fcdeac
commit a268fec7f5
5 changed files with 72 additions and 20 deletions

View File

@@ -1,3 +1,6 @@
1915. [func] dig now has a '-q queryname' and '+showsearch' options.
[RT #15034]
1914. [bug] Strings returned from cfg_obj_asstring() should be 1914. [bug] Strings returned from cfg_obj_asstring() should be
treated as read-only. The prototype for treated as read-only. The prototype for
cfg_obj_asstring() has been updated to reflect this. cfg_obj_asstring() has been updated to reflect this.

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: dig.c,v 1.205 2005/07/04 03:03:20 marka Exp $ */ /* $Id: dig.c,v 1.206 2005/08/25 00:17:45 marka Exp $ */
/*! \file */ /*! \file */
@@ -148,6 +148,7 @@ help(void) {
" -f filename (batch mode)\n" " -f filename (batch mode)\n"
" -b address[#port] (bind to source address/port)\n" " -b address[#port] (bind to source address/port)\n"
" -p port (specify port number)\n" " -p port (specify port number)\n"
" -q name (specify query name)\n"
" -t type (specify query type)\n" " -t type (specify query type)\n"
" -c class (specify query class)\n" " -c class (specify query class)\n"
" -k keyfile (specify tsig key file)\n" " -k keyfile (specify tsig key file)\n"
@@ -165,6 +166,7 @@ help(void) {
" +ndots=### (Set NDOTS value)\n" " +ndots=### (Set NDOTS value)\n"
" +edns=### (Set EDNS version)\n" " +edns=### (Set EDNS version)\n"
" +[no]search (Set whether to use searchlist)\n" " +[no]search (Set whether to use searchlist)\n"
" +[no]showsearch (Search with intermediate results)\n"
" +[no]defname (Ditto)\n" " +[no]defname (Ditto)\n"
" +[no]recurse (Recursive mode)\n" " +[no]recurse (Recursive mode)\n"
" +[no]ignore (Don't revert to TCP for TC responses.)" " +[no]ignore (Don't revert to TCP for TC responses.)"
@@ -956,17 +958,30 @@ plus_option(char *option, isc_boolean_t is_batchfile,
FULLCHECK("search"); FULLCHECK("search");
usesearch = state; usesearch = state;
break; break;
case 'h': /* short */ case 'h':
FULLCHECK("short"); if (cmd[2] != 'o')
short_form = state; goto invalid_option;
if (state) { switch (cmd[3]) {
printcmd = ISC_FALSE; case 'r': /* short */
lookup->section_additional = ISC_FALSE; FULLCHECK("short");
lookup->section_answer = ISC_TRUE; short_form = state;
lookup->section_authority = ISC_FALSE; if (state) {
lookup->section_question = ISC_FALSE; printcmd = ISC_FALSE;
lookup->comments = ISC_FALSE; lookup->section_additional = ISC_FALSE;
lookup->stats = ISC_FALSE; lookup->section_answer = ISC_TRUE;
lookup->section_authority = ISC_FALSE;
lookup->section_question = ISC_FALSE;
lookup->comments = ISC_FALSE;
lookup->stats = ISC_FALSE;
}
break;
case 'w': /* showsearch */
FULLCHECK("showsearch");
showsearch = state;
usesearch = state;
break;
default:
goto invalid_option;
} }
break; break;
#ifdef DIG_SIGCHASE #ifdef DIG_SIGCHASE
@@ -1082,7 +1097,7 @@ static const char *single_dash_opts = "46dhimnv";
static const char *dash_opts = "46bcdfhikmnptvyx"; static const char *dash_opts = "46bcdfhikmnptvyx";
static isc_boolean_t static isc_boolean_t
dash_option(char *option, char *next, dig_lookup_t **lookup, dash_option(char *option, char *next, dig_lookup_t **lookup,
isc_boolean_t *open_type_class) isc_boolean_t *open_type_class, isc_boolean_t config_only)
{ {
char opt, *value, *ptr; char opt, *value, *ptr;
isc_result_t result; isc_result_t result;
@@ -1217,6 +1232,20 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
case 'p': case 'p':
port = (in_port_t) parse_uint(value, "port number", MAXPORT); port = (in_port_t) parse_uint(value, "port number", MAXPORT);
return (value_from_next); return (value_from_next);
case 'q':
if (!config_only) {
(*lookup) = clone_lookup(default_lookup,
ISC_TRUE);
strncpy((*lookup)->textname, value,
sizeof((*lookup)->textname));
(*lookup)->textname[sizeof((*lookup)->textname)-1]=0;
(*lookup)->trace_root = ISC_TF((*lookup)->trace ||
(*lookup)->ns_search_only);
(*lookup)->new_search = ISC_TRUE;
ISC_LIST_APPEND(lookup_list, (*lookup), link);
debug("looking up %s", (*lookup)->textname);
}
return (value_from_next);
case 't': case 't':
*open_type_class = ISC_FALSE; *open_type_class = ISC_FALSE;
if (strncasecmp(value, "ixfr=", 5) == 0) { if (strncasecmp(value, "ixfr=", 5) == 0) {
@@ -1450,13 +1479,15 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only,
} else if (rv[0][0] == '-') { } else if (rv[0][0] == '-') {
if (rc <= 1) { if (rc <= 1) {
if (dash_option(&rv[0][1], NULL, if (dash_option(&rv[0][1], NULL,
&lookup, &open_type_class)) { &lookup, &open_type_class,
config_only)) {
rc--; rc--;
rv++; rv++;
} }
} else { } else {
if (dash_option(&rv[0][1], rv[1], if (dash_option(&rv[0][1], rv[1],
&lookup, &open_type_class)) { &lookup, &open_type_class,
config_only)) {
rc--; rc--;
rv++; rv++;
} }

View File

@@ -18,7 +18,7 @@
- PERFORMANCE OF THIS SOFTWARE. - PERFORMANCE OF THIS SOFTWARE.
--> -->
<!-- $Id: dig.docbook,v 1.24 2005/07/19 04:55:19 marka Exp $ --> <!-- $Id: dig.docbook,v 1.25 2005/08/25 00:17:46 marka Exp $ -->
<refentry id="man.dig"> <refentry id="man.dig">
<refentryinfo> <refentryinfo>
@@ -60,6 +60,7 @@
<arg><option>-f <replaceable class="parameter">filename</replaceable></option></arg> <arg><option>-f <replaceable class="parameter">filename</replaceable></option></arg>
<arg><option>-k <replaceable class="parameter">filename</replaceable></option></arg> <arg><option>-k <replaceable class="parameter">filename</replaceable></option></arg>
<arg><option>-p <replaceable class="parameter">port#</replaceable></option></arg> <arg><option>-p <replaceable class="parameter">port#</replaceable></option></arg>
<arg><option>-q <replaceable class="parameter">name</replaceable></option></arg>
<arg><option>-t <replaceable class="parameter">type</replaceable></option></arg> <arg><option>-t <replaceable class="parameter">type</replaceable></option></arg>
<arg><option>-x <replaceable class="parameter">addr</replaceable></option></arg> <arg><option>-x <replaceable class="parameter">addr</replaceable></option></arg>
<arg><option>-y <replaceable class="parameter">name:key</replaceable></option></arg> <arg><option>-y <replaceable class="parameter">name:key</replaceable></option></arg>
@@ -250,6 +251,12 @@
<parameter>N</parameter>. <parameter>N</parameter>.
</para> </para>
<para>
The <option>-q</option> option sets the query name to
<parameter>name</parameter>. This useful do distingish the
<parameter>name</parameter> from other arguements.
</para>
<para> <para>
Reverse lookups - mapping addresses to names - are simplified by the Reverse lookups - mapping addresses to names - are simplified by the
<option>-x</option> option. <parameter>addr</parameter> is <option>-x</option> option. <parameter>addr</parameter> is
@@ -384,6 +391,16 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>+[no]showsearch</option></term>
<listitem>
<para>
Perform [do not perform] a search showing intermediate
results.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>+[no]defname</option></term> <term><option>+[no]defname</option></term>
<listitem> <listitem>

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: dighost.c,v 1.280 2005/07/04 03:03:20 marka Exp $ */ /* $Id: dighost.c,v 1.281 2005/08/25 00:17:46 marka Exp $ */
/*! \file /*! \file
* \note * \note
@@ -102,6 +102,7 @@ isc_boolean_t
free_now = ISC_FALSE, free_now = ISC_FALSE,
cancel_now = ISC_FALSE, cancel_now = ISC_FALSE,
usesearch = ISC_FALSE, usesearch = ISC_FALSE,
showsearch = ISC_FALSE,
qr = ISC_FALSE, qr = ISC_FALSE,
is_dst_up = ISC_FALSE; is_dst_up = ISC_FALSE;
in_port_t port = 53; in_port_t port = 53;
@@ -2893,7 +2894,7 @@ recv_done(isc_task_t *task, isc_event_t *event) {
if (!l->doing_xfr || l->xfr_q == query) { if (!l->doing_xfr || l->xfr_q == query) {
if (msg->rcode != dns_rcode_noerror && l->origin != NULL) { if (msg->rcode != dns_rcode_noerror && l->origin != NULL) {
if (!next_origin(msg, query)) { if (!next_origin(msg, query) || showsearch) {
printmessage(query, msg, ISC_TRUE); printmessage(query, msg, ISC_TRUE);
received(b->used, &sevent->address, query); received(b->used, &sevent->address, query);
} }

View File

@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: dig.h,v 1.94 2005/07/04 03:03:21 marka Exp $ */ /* $Id: dig.h,v 1.95 2005/08/25 00:17:46 marka Exp $ */
#ifndef DIG_H #ifndef DIG_H
#define DIG_H #define DIG_H
@@ -244,7 +244,7 @@ extern dig_searchlistlist_t search_list;
extern unsigned int extrabytes; extern unsigned int extrabytes;
extern isc_boolean_t have_ipv4, have_ipv6, specified_source, extern isc_boolean_t have_ipv4, have_ipv6, specified_source,
usesearch, qr; usesearch, showsearch, qr;
extern in_port_t port; extern in_port_t port;
extern unsigned int timeout; extern unsigned int timeout;
extern isc_mem_t *mctx; extern isc_mem_t *mctx;