summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-10-17 21:28:56 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2020-10-17 21:28:56 +0200
commit0b094303f3e30007fd9fccc3df81f44cf2c49003 (patch)
treed16f56eb41ad176f026d6c022d0713d440dbb62e /sys
parentbf187247380252d3f79ad7089251600b7535815e (diff)
ndb/dnsdebug: add -c flag to debug caching dns server behaviour
Diffstat (limited to 'sys')
-rw-r--r--sys/man/8/ndb5
-rw-r--r--sys/src/cmd/ndb/dnsdebug.c16
2 files changed, 19 insertions, 2 deletions
diff --git a/sys/man/8/ndb b/sys/man/8/ndb
index af4df056d..f6da3bbb8 100644
--- a/sys/man/8/ndb
+++ b/sys/man/8/ndb
@@ -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
diff --git a/sys/src/cmd/ndb/dnsdebug.c b/sys/src/cmd/ndb/dnsdebug.c
index 092e0c7b3..650e705d9 100644
--- a/sys/src/cmd/ndb/dnsdebug.c
+++ b/sys/src/cmd/ndb/dnsdebug.c
@@ -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)