diff options
| author | Adam <Adam@anope.org> | 2012-10-22 17:02:01 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2012-10-22 17:02:01 -0400 |
| commit | 04632bd381796dd90742bbc6ccd38905d4de25be (patch) | |
| tree | f9b8cf382037a44f7dba45dd5d5f186f43428a0e /modules | |
| parent | 0b9db15efc322336ddb08671ce68a3d45fb22520 (diff) | |
Cleanup of last few commits/warning fix
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/commands/os_dns.cpp | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp index 5a4e3e1c3..d1c20f0a4 100644 --- a/modules/commands/os_dns.cpp +++ b/modules/commands/os_dns.cpp @@ -490,15 +490,14 @@ class ModuleDNS : public Module } } - void OnDnsRequest(DNSPacket &req) anope_override + void OnDnsRequest(DNSPacket &req, DNSPacket *packet) anope_override { if (req.questions.empty()) return; - /* Currently we reply to any QR */ + /* Currently we reply to any QR for A/AAAA */ const Question& q = req.questions[0]; - - DNSPacket *packet = new DNSPacket(req); - packet->flags |= DNS_QUERYFLAGS_QR; /* This is a reponse */ + if (q.type != DNS_QUERY_A && q.type != DNS_QUERY_AAAA) + return; for (unsigned i = 0; i < dns_servers.size(); ++i) { @@ -508,10 +507,15 @@ class ModuleDNS : public Module for (unsigned j = 0; j < s->GetIPs().size(); ++j) { - ResourceRecord rr(q.name, s->GetIPs()[j].find(':') != Anope::string::npos ? DNS_QUERY_AAAA : DNS_QUERY_A); - rr.ttl = this->ttl; - rr.rdata = s->GetIPs()[j]; - packet->answers.push_back(rr); + QueryType q_type = s->GetIPs()[j].find(':') != Anope::string::npos ? DNS_QUERY_AAAA : DNS_QUERY_A; + + if (q_type == q.type) + { + ResourceRecord rr(q.name, q_type); + rr.ttl = this->ttl; + rr.rdata = s->GetIPs()[j]; + packet->answers.push_back(rr); + } } } @@ -531,10 +535,15 @@ class ModuleDNS : public Module for (unsigned j = 0; j < s->GetIPs().size(); ++j) { - ResourceRecord rr(q.name, s->GetIPs()[j].find(':') != Anope::string::npos ? DNS_QUERY_AAAA : DNS_QUERY_A); - rr.ttl = this->ttl; - rr.rdata = s->GetIPs()[j]; - packet->answers.push_back(rr); + QueryType q_type = s->GetIPs()[j].find(':') != Anope::string::npos ? DNS_QUERY_AAAA : DNS_QUERY_A; + + if (q_type == q.type) + { + ResourceRecord rr(q.name, q_type); + rr.ttl = this->ttl; + rr.rdata = s->GetIPs()[j]; + packet->answers.push_back(rr); + } } } @@ -544,8 +553,6 @@ class ModuleDNS : public Module /* Send back an empty answer anyway */ } } - - DNSEngine->SendPacket(packet); } }; |
