ref: 0b094303f3e30007fd9fccc3df81f44cf2c49003
parent: bf187247380252d3f79ad7089251600b7535815e
author: cinap_lenrek <[email protected]>
date: Sat Oct 17 17:28:56 EDT 2020
ndb/dnsdebug: add -c flag to debug caching dns server behaviour
--- a/sys/man/8/ndb
+++ b/sys/man/8/ndb
@@ -97,7 +97,7 @@
.br
.B ndb/dnsdebug
[
-.B -rx
+.B -rxc
] [
.B -f
.I dbfile
@@ -758,6 +758,9 @@
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
--- a/sys/src/cmd/ndb/dnsdebug.c
+++ b/sys/src/cmd/ndb/dnsdebug.c
@@ -56,9 +56,16 @@
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 @@
fmtinstall('R', prettyrrfmt);
opendatabase();
srand(truerand());
+ db2cache(1);
if(cfg.resolver)
squirrelserveraddrs();
@@ -89,7 +97,6 @@
p[Blinelen(&in)-1] = 0;
n = tokenize(p, f, 3);
if(n>=1) {
- dnpurge(); /* flush the cache */
docmd(n, f);
}
}
@@ -457,6 +464,12 @@
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 @@
if(name == nil)
return;
+ if(!cfg.cachedb) dnpurge(); /* flush the cache */
doquery(name, type);
if(tmpsrv)