void Bind2Backend::lookup(const QType &qtype, const DNSName &qname, int zoneId, DNSPacket *pkt_p )
{
d_handle.reset();
- DNSName domain(qname);
static bool mustlog=::arg().mustDo("query-logging");
- if(mustlog)
- g_log<<Logger::Warning<<"Lookup for '"<<qtype.getName()<<"' of '"<<domain<<"' within zoneID "<<zoneId<<endl;
- bool found=false;
+
+ bool found;
+ DNSName domain;
BB2DomainInfo bbd;
- do {
- found = safeGetBBDomainInfo(domain, &bbd);
- } while ((!found || (zoneId != (int)bbd.d_id && zoneId != -1)) && qtype != QType::SOA && domain.chopOff());
+ if(mustlog)
+ g_log<<Logger::Warning<<"Lookup for '"<<qtype.getName()<<"' of '"<<qname<<"' within zoneID "<<zoneId<<endl;
+
+ if (zoneId >= 0) {
+ if ((found = safeGetBBDomainInfo(zoneId, &bbd))) {
+ domain = bbd.d_name;
+ }
+ } else {
+ domain = qname;
+ do {
+ found = safeGetBBDomainInfo(domain, &bbd);
+ } while (!found && qtype != QType::SOA && domain.chopOff());
+ }
if(!found) {
if(mustlog)
if(mustlog)
g_log<<Logger::Warning<<"Found a zone '"<<domain<<"' (with id " << bbd.d_id<<") that might contain data "<<endl;
-
+
d_handle.id=bbd.d_id;
-
- DLOG(g_log<<"Bind2Backend constructing handle for search for "<<qtype.getName()<<" for "<<
- qname<<endl);
-
+
if(domain.empty())
d_handle.qname=qname;
else if(qname.isPartOf(domain))