ndb/dnsdebug: add -c flag to debug caching dns server behaviour

This commit is contained in:
cinap_lenrek 2020-10-17 21:28:56 +02:00
parent bf18724738
commit 0b094303f3
2 changed files with 19 additions and 2 deletions

View file

@ -97,7 +97,7 @@ query, ipquery, mkhash, mkdb, mkhosts, cs, csquery, dns, dnstcp, dnsquery, dnsde
.br
.B ndb/dnsdebug
[
.B -rx
.B -rxc
] [
.B -f
.I dbfile
@ -758,6 +758,9 @@ to use the
interface and
.B /lib/ndb/external
database file.
The
.B -c
option enables caching which is handy for debugging the dns code.
.PP
.I Ndb/dnsgetip
resolves and prints A and AAAA records without consulting

View file

@ -56,9 +56,16 @@ main(int argc, char *argv[])
case 'f':
dbfile = EARGF(usage());
break;
case 'c':
cfg.cachedb = 1;
break;
case 'r':
cfg.resolver = 1;
break;
case 'd':
debug = 1;
traceactivity = 1;
break;
case 'x':
dbfile = "/lib/ndb/external";
strcpy(mntpt, "/net.alt");
@ -73,6 +80,7 @@ main(int argc, char *argv[])
fmtinstall('R', prettyrrfmt);
opendatabase();
srand(truerand());
db2cache(1);
if(cfg.resolver)
squirrelserveraddrs();
@ -89,7 +97,6 @@ main(int argc, char *argv[])
p[Blinelen(&in)-1] = 0;
n = tokenize(p, f, 3);
if(n>=1) {
dnpurge(); /* flush the cache */
docmd(n, f);
}
}
@ -457,6 +464,12 @@ docmd(int n, char **f)
name = type = nil;
tmpsrv = 0;
if(strcmp(f[0], "refresh") == 0){
db2cache(1);
dnageall(0);
return;
}
if(*f[0] == '@') {
if(setserver(f[0]+1) < 0)
return;
@ -483,6 +496,7 @@ docmd(int n, char **f)
if(name == nil)
return;
if(!cfg.cachedb) dnpurge(); /* flush the cache */
doquery(name, type);
if(tmpsrv)