aboutsummaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree/resolvers.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2021-12-27 10:53:36 +0000
committerGravatar Sadie Powell2021-12-27 10:53:36 +0000
commitcdab76406fbeb6c74a403ea640b2209ea02eb86c (patch)
treebe099b1338e10d3144188c6f5fd60b11a4817e0f /src/modules/m_spanningtree/resolvers.cpp
parentMake all extensibles use kebab-case for names where possible. (diff)
parentFix not being able to look up hostnames that point to multiple IPs. (diff)
Merge branch 'insp3' into master.
Diffstat (limited to 'src/modules/m_spanningtree/resolvers.cpp')
-rw-r--r--src/modules/m_spanningtree/resolvers.cpp47
1 files changed, 31 insertions, 16 deletions
diff --git a/src/modules/m_spanningtree/resolvers.cpp b/src/modules/m_spanningtree/resolvers.cpp
index 9bf5a4b17..c827b89f5 100644
--- a/src/modules/m_spanningtree/resolvers.cpp
+++ b/src/modules/m_spanningtree/resolvers.cpp
@@ -113,6 +113,25 @@ SecurityIPResolver::SecurityIPResolver(Module* me, DNS::Manager* mgr, const std:
{
}
+bool SecurityIPResolver::CheckIPv4()
+{
+ // We only check IPv4 addresses if we have checked IPv6.
+ if (query != DNS::QUERY_AAAA)
+ return false;
+
+ SecurityIPResolver* res = new SecurityIPResolver(mine, this->manager, host, MyLink, DNS::QUERY_A);
+ try
+ {
+ this->manager->Process(res);
+ return true;
+ }
+ catch (const DNS::Exception&)
+ {
+ delete res;
+ return false;
+ }
+}
+
void SecurityIPResolver::OnLookupComplete(const DNS::Query *r)
{
for (std::shared_ptr<Link> L : Utils->LinkBlocks)
@@ -121,31 +140,27 @@ void SecurityIPResolver::OnLookupComplete(const DNS::Query *r)
{
for (const auto& ans_record : r->answers)
{
- if (ans_record.type == this->question.type)
- Utils->ValidIPs.push_back(ans_record.rdata);
+ if (ans_record.type != this->question.type)
+ continue;
+
+ Utils->ValidIPs.push_back(ans_record.rdata);
+ ServerInstance->Logs.Log(MODNAME, LOG_DEFAULT, "Resolved '%s' as a valid IP address for link '%s'",
+ ans_record.rdata.c_str(), MyLink->Name.c_str());
}
break;
}
}
+
+ CheckIPv4();
}
void SecurityIPResolver::OnError(const DNS::Query *r)
{
// This can be called because of us being unloaded but we don't have to do anything differently
- if (query == DNS::QUERY_AAAA)
- {
- SecurityIPResolver* res = new SecurityIPResolver(mine, this->manager, host, MyLink, DNS::QUERY_A);
- try
- {
- this->manager->Process(res);
- return;
- }
- catch (DNS::Exception &)
- {
- delete res;
- }
- }
- ServerInstance->Logs.Log(MODNAME, LOG_DEFAULT, "Could not resolve IP associated with Link '%s': %s",
+ if (CheckIPv4())
+ return;
+
+ ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Could not resolve IP associated with link '%s': %s",
MyLink->Name.c_str(), this->manager->GetErrorStr(r->error).c_str());
}