From: Aki Tuomi Date: Fri, 11 Sep 2015 08:18:14 +0000 (+0300) Subject: Return result directly if available X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~44^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65f7b8ec195064e067229db372001118069b18b9;p=pdns Return result directly if available --- diff --git a/modules/geoipbackend/geoipbackend.cc b/modules/geoipbackend/geoipbackend.cc index 2e7d2acc7..d4bf173fb 100644 --- a/modules/geoipbackend/geoipbackend.cc +++ b/modules/geoipbackend/geoipbackend.cc @@ -180,8 +180,6 @@ void GeoIPBackend::lookup(const QType &qtype, const DNSName& qdomain, DNSPacket return; } - if (!(qtype == QType::ANY || qtype == QType::CNAME)) return; - string ip = "0.0.0.0"; bool v6 = false; if (pkt_p != NULL) { @@ -195,6 +193,20 @@ void GeoIPBackend::lookup(const QType &qtype, const DNSName& qdomain, DNSPacket format = format2str(format, ip, v6); + // see if the record can be found + if (dom.records.count(format)) { // return static value + map >::iterator i = dom.records.find(format); + BOOST_FOREACH(DNSResourceRecord rr, i->second) { + if (qtype == QType::ANY || rr.qtype == qtype) { + d_result.push_back(rr); + d_result.back().qname = qdomain; + } + } + return; + } + + if (!(qtype == QType::ANY || qtype == QType::CNAME)) return; + DNSResourceRecord rr; rr.domain_id = dom.id; rr.qtype = QType::CNAME;