Permalink
Browse files

Return result directly if available

  • Loading branch information...
1 parent a7127f7 commit 69ea1a6e641e56d369378ef3d858464201f7769f @cmouse cmouse committed with cmouse Sep 11, 2015
Showing with 14 additions and 2 deletions.
  1. +14 −2 modules/geoipbackend/geoipbackend.cc
@@ -188,8 +188,6 @@ void GeoIPBackend::lookup(const QType &qtype, const string &qdomain, DNSPacket *
return;
}
- if (!(qtype == QType::ANY || qtype == QType::CNAME)) return;
-
string ip = "0.0.0.0";
bool v6 = false;
if (pkt_p != NULL) {
@@ -203,6 +201,20 @@ void GeoIPBackend::lookup(const QType &qtype, const string &qdomain, DNSPacket *
format = format2str(format, ip, v6);
+ // see if the record can be found
+ if (dom.records.count(format)) { // return static value
+ map<DNSName, vector<DNSResourceRecord> >::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;

0 comments on commit 69ea1a6

Please sign in to comment.