--- dnscache.c.orig Mon Feb 26 20:41:13 2001 +++ dnscache.c Mon Feb 26 20:40:40 2001 @@ -389,6 +389,7 @@ int main() { char *x; + char nxdip[4]; unsigned long cachesize; x = env_get("IP"); @@ -435,6 +436,13 @@ response_hidettl(); if (env_get("FORWARDONLY")) query_forwardonly(); + + x = env_get("NXDSPECIAL"); + if (x) { + if (!ip4_scan(x,nxdip)) + strerr_die3x(111,FATAL,"unable to parse NXDSPECIAL IP address ",x); + query_nxdspecial(nxdip); + } if (!roots_init()) strerr_die2sys(111,FATAL,"unable to read servers: "); --- query.c.orig Mon Feb 26 20:41:21 2001 +++ query.c Mon Feb 26 20:08:33 2001 @@ -20,6 +20,15 @@ flagforwardonly = 1; } +static int flagnxdspecial = 0; +static char nxdip[4]; + +void query_nxdspecial(const char ip[4]) +{ + byte_copy(nxdip,4,ip); + flagnxdspecial = 1; +} + static void cachegeneric(const char type[2],const char *d,const char *data,unsigned int datalen,uint32 ttl) { unsigned int len; @@ -246,6 +255,7 @@ case_lowerb(key + 2,dlen); cached = cache_get(key,dlen + 2,&cachedlen,&ttl); if (cached) { + soattl = rcode = 0; log_cachednxdomain(d); goto NXDOMAIN; } @@ -695,7 +705,12 @@ NXDOMAIN: if (z->level) goto LOWERLEVEL; if (!rqa(z)) goto DIE; - response_nxdomain(); + if (flagnxdspecial && typematch(DNS_T_A,dtype)) { + if (!response_rstart(d,DNS_T_A,rcode == 3 ? soattl : ttl)) goto DIE; + if (!response_addbytes(nxdip,4)) goto DIE; + response_rfinish(RESPONSE_ANSWER); + } else + response_nxdomain(); cleanup(z); return 1; } --- query.h.orig Mon Feb 26 20:41:29 2001 +++ query.h Mon Feb 26 20:02:59 2001 @@ -28,5 +28,6 @@ extern int query_get(struct query *,iopause_fd *,struct taia *); extern void query_forwardonly(void); +extern void query_nxdspecial(const char *); #endif