ndb/dnsgetip: report errors when dns resolution fails
This commit is contained in:
parent
96e511d736
commit
c5559504cd
1 changed files with 40 additions and 9 deletions
|
@ -18,27 +18,49 @@ int testing = 0;
|
||||||
int traceactivity = 0;
|
int traceactivity = 0;
|
||||||
char *zonerefreshprogram;
|
char *zonerefreshprogram;
|
||||||
|
|
||||||
int aflag;
|
int aflag = 0;
|
||||||
|
int addresses = 0;
|
||||||
|
|
||||||
void
|
char Ebotch[] = "dns botch";
|
||||||
|
|
||||||
|
char*
|
||||||
resolve(char *name, int type)
|
resolve(char *name, int type)
|
||||||
{
|
{
|
||||||
|
int status;
|
||||||
|
char *errmsg;
|
||||||
Request req;
|
Request req;
|
||||||
RR *rp;
|
RR *rr, *rp, *neg;
|
||||||
|
|
||||||
|
status = Rok;
|
||||||
|
errmsg = nil;
|
||||||
|
|
||||||
memset(&req, 0, sizeof req);
|
memset(&req, 0, sizeof req);
|
||||||
getactivity(&req, 0);
|
getactivity(&req, 0);
|
||||||
req.isslave = 1;
|
req.isslave = 1;
|
||||||
req.aborttime = NS2MS(nowns) + Maxreqtm;
|
req.aborttime = NS2MS(nowns) + Maxreqtm;
|
||||||
|
|
||||||
rp = dnresolve(name, Cin, type, &req, 0, 0, Recurse, 0, 0);
|
rr = dnresolve(name, Cin, type, &req, 0, 0, Recurse, 0, &status);
|
||||||
rrremneg(&rp);
|
neg = rrremneg(&rr);
|
||||||
while(rp != nil){
|
if(rr == nil || neg != nil){
|
||||||
|
if(neg != nil)
|
||||||
|
status = neg->negrcode;
|
||||||
|
errmsg = Ebotch;
|
||||||
|
if(status > 0 && status < nrname)
|
||||||
|
errmsg = rname[status];
|
||||||
|
}
|
||||||
|
|
||||||
|
rrfreelist(neg);
|
||||||
|
|
||||||
|
for(rp = rr; rp != nil; rp = rp->next){
|
||||||
print("%s\n", rp->ip->name);
|
print("%s\n", rp->ip->name);
|
||||||
|
addresses++;
|
||||||
if(!aflag)
|
if(!aflag)
|
||||||
exits(nil);
|
exits(nil);
|
||||||
rp = rp->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rrfreelist(rr);
|
||||||
|
|
||||||
|
return errmsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -51,6 +73,8 @@ usage(void)
|
||||||
void
|
void
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
char *e4, *e6;
|
||||||
|
|
||||||
strcpy(mntpt, "/net");
|
strcpy(mntpt, "/net");
|
||||||
cfg.inside = 1;
|
cfg.inside = 1;
|
||||||
cfg.resolver = 1;
|
cfg.resolver = 1;
|
||||||
|
@ -76,8 +100,15 @@ main(int argc, char **argv)
|
||||||
print("%s\n", *argv);
|
print("%s\n", *argv);
|
||||||
else {
|
else {
|
||||||
dninit();
|
dninit();
|
||||||
resolve(*argv, Ta);
|
e4 = resolve(*argv, Ta);
|
||||||
resolve(*argv, Taaaa);
|
e6 = resolve(*argv, Taaaa);
|
||||||
|
|
||||||
|
if(addresses == 0){
|
||||||
|
if(e4 == e6)
|
||||||
|
sysfatal("%s: dns failure: %s", *argv, e4);
|
||||||
|
|
||||||
|
sysfatal("%s: dns failure: v4: %s: v6: %s", *argv, e4, e6);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exits(nil);
|
exits(nil);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue