ref: 24611cf5ed0f34edc6b843a621b63b710f51570a
parent: a8a642920444ec6689ccfae81a1b1e148f75190e
author: cinap_lenrek <[email protected]>
date: Tue Jul 10 15:57:55 EDT 2018
ndb/cs: add -6 flag for v6 only lookups and "ipv4" control message to toggle v4 lookups.
--- a/sys/man/8/ndb
+++ b/sys/man/8/ndb
@@ -35,7 +35,7 @@
.br
.B ndb/cs
[
-.B -4n
+.B -46n
] [
.B -f
.I dbfile
@@ -257,10 +257,18 @@
Only look up IPv4 addresses (A records) when consulting DNS.
The default is to also look up v6 addresses (AAAA records).
Writing
+.L ipv4
+to
+.B /net/cs
+will toggle IP v4 look-ups.
+.TP
+.B -6
+Only look up IPv6 addresses in DNS.
+Writing
.L ipv6
to
.B /net/cs
-will toggle IP v6 look-ups.
+toggles v6 lookups.
.TP
.B -f
supplies the name of the data base file to use,
--- a/sys/src/cmd/ndb/cs.c
+++ b/sys/src/cmd/ndb/cs.c
@@ -196,7 +196,7 @@
void
usage(void)
{
- fprint(2, "usage: %s [-dn] [-f ndb-file] [-x netmtpt]\n", argv0);
+ fprint(2, "usage: %s [-46dn] [-f ndb-file] [-x netmtpt]\n", argv0);
exits("usage");
}
@@ -238,6 +238,9 @@
case '4':
lookipvers = V4;
break;
+ case '6':
+ lookipvers = V6;
+ break;
case 'd':
debug = 1;
break;
@@ -796,6 +799,15 @@
if(strncmp(job->request.data, "debug", 5)==0){
debug ^= 1;
syslog(1, logfile, "debug %d", debug);
+ goto send;
+ }
+
+ /*
+ * toggle ipv4 lookups
+ */
+ if(strncmp(job->request.data, "ipv4", 4)==0){
+ lookipvers ^= V4;
+ syslog(1, logfile, "ipv4lookups %d", (lookipvers & V4) != 0);
goto send;
}