ref: 9c2e8e2b13b0d01b7adf88b61af6edfbddd872c1
parent: 53fe82ee861967f0c02dbec7901660470da79098
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Jan 14 22:59:10 EST 2024
ndb/dnsdebug: fix dnsserver override (thanks moody)
--- a/sys/src/cmd/ndb/dnresolve.c
+++ b/sys/src/cmd/ndb/dnresolve.c
@@ -1227,9 +1227,10 @@
for(rp = qp->nsrp; rp; rp = rp->next)
rp->marker = 0;
- /* request recursion only for local dns servers */
+ /* request recursion only for local/override dns servers */
flag = Oquery;
- if(strncmp(qp->nsrp->owner->name, "local#", 6) == 0)
+ if(strncmp(qp->nsrp->owner->name, "local#", 6) == 0
+ || strncmp(qp->nsrp->owner->name, "override#", 9) == 0)
flag |= Frecurse;
/* pack request into a udp message */
--- a/sys/src/cmd/ndb/dnsdebug.c
+++ b/sys/src/cmd/ndb/dnsdebug.c
@@ -170,15 +170,27 @@
RR*
getdnsservers(int class)
{
- RR *rr;
+ uchar ip[IPaddrlen];
+ DN *nsdp;
+ RR *rp;
if(servername == nil)
return dnsservers(class);
-
- rr = rralloc(Tns);
- rr->owner = dnlookup("local#dns#servers", class, 1);
- rr->host = idnlookup(servername, class, 1);
- return rr;
+ if(parseip(ip, servername) == -1){
+ nsdp = idnlookup(servername, class, 1);
+ } else {
+ nsdp = dnlookup("local#dns#server", class, 1);
+ rp = rralloc(isv4(ip) ? Ta : Taaaa);
+ rp->owner = nsdp;
+ rp->ip = ipalookup(ip, class, 1);
+ rp->db = 1;
+ rp->ttl = 10*Min;
+ rrattach(rp, Authoritative);
+ }
+ rp = rralloc(Tns);
+ rp->owner = dnlookup("override#dns#servers", class, 1);
+ rp->host = nsdp;
+ return rp;
}
int