summaryrefslogtreecommitdiff
path: root/src/coremods
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-08-16 12:43:40 -0400
committerAttila Molnar <attilamolnar@hush.com>2016-08-25 17:12:48 +0200
commit14556541bb12fda6e7af8273458f680386e9c438 (patch)
tree4b5f1855562785fbfe669794710e6da9a7d2b08f /src/coremods
parent5c1b64735597e11f2336302ede671e5060f576ff (diff)
core_dns Make question a member of request, move common FindAnswerOfType to be a member of query
Diffstat (limited to 'src/coremods')
-rw-r--r--src/coremods/core_dns.cpp14
-rw-r--r--src/coremods/core_hostname_lookup.cpp19
2 files changed, 9 insertions, 24 deletions
diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp
index 25182eb1b..c95d42ea3 100644
--- a/src/coremods/core_dns.cpp
+++ b/src/coremods/core_dns.cpp
@@ -416,7 +416,7 @@ class MyManager : public Manager, public Timer, public EventHandler
if (!request)
continue;
- Query rr(*request);
+ Query rr(request->question);
rr.error = ERROR_UNKNOWN;
request->OnError(&rr);
@@ -426,7 +426,7 @@ class MyManager : public Manager, public Timer, public EventHandler
void Process(DNS::Request* req)
{
- ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Processing request to lookup " + req->name + " of type " + ConvToStr(req->type) + " to " + this->myserver.addr());
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Processing request to lookup " + req->question.name + " of type " + ConvToStr(req->question.type) + " to " + this->myserver.addr());
/* Create an id */
unsigned int tries = 0;
@@ -463,7 +463,7 @@ class MyManager : public Manager, public Timer, public EventHandler
Packet p;
p.flags = QUERYFLAGS_RD;
p.id = req->id;
- p.question = *req;
+ p.question = req->question;
unsigned char buffer[524];
unsigned short len = p.Pack(buffer, sizeof(buffer));
@@ -479,7 +479,7 @@ class MyManager : public Manager, public Timer, public EventHandler
}
// Update name in the original request so question checking works for PTR queries
- req->name = p.question.name;
+ req->question.name = p.question.name;
if (SocketEngine::SendTo(this, buffer, len, 0, &this->myserver.sa, this->myserver.sa_size()) != len)
throw Exception("DNS: Unable to send query");
@@ -568,7 +568,7 @@ class MyManager : public Manager, public Timer, public EventHandler
return;
}
- if (static_cast<Question&>(*request) != recv_packet.question)
+ if (request->question != recv_packet.question)
{
// This can happen under high latency, drop it silently, do not fail the request
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Received an answer that isn't for a question we asked");
@@ -631,7 +631,7 @@ class MyManager : public Manager, public Timer, public EventHandler
}
else
{
- ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Lookup complete for " + request->name);
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Lookup complete for " + request->question.name);
ServerInstance->stats.DnsGood++;
request->OnLookupComplete(&recv_packet);
this->AddCache(recv_packet);
@@ -815,7 +815,7 @@ class ModuleDNS : public Module
if (req->creator == mod)
{
- Query rr(*req);
+ Query rr(req->question);
rr.error = ERROR_UNLOADED;
req->OnError(&rr);
diff --git a/src/coremods/core_hostname_lookup.cpp b/src/coremods/core_hostname_lookup.cpp
index cbd80931c..b9adc9c2e 100644
--- a/src/coremods/core_hostname_lookup.cpp
+++ b/src/coremods/core_hostname_lookup.cpp
@@ -37,21 +37,6 @@ class UserResolver : public DNS::Request
*/
const bool fwd;
- const DNS::ResourceRecord* FindAnswerOfType(const DNS::Query* response, DNS::QueryType qtype)
- {
- for (std::vector<DNS::ResourceRecord>::const_iterator it = response->answers.begin(); it != response->answers.end(); ++it)
- {
- const DNS::ResourceRecord& rr = *it;
-
- if (rr.type == qtype)
- {
- return &rr;
- }
- }
-
- return NULL;
- }
-
public:
/** Create a resolver.
* @param mgr DNS Manager
@@ -80,10 +65,10 @@ class UserResolver : public DNS::Request
return;
}
- const DNS::ResourceRecord* ans_record = FindAnswerOfType(r, this->type);
+ const DNS::ResourceRecord* ans_record = r->FindAnswerOfType(this->question.type);
if (ans_record == NULL)
{
- ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "DNS result for %s: no record of type %d", uuid.c_str(), this->type);
+ OnError(r);
return;
}