diff options
| author | 2021-12-27 10:53:36 +0000 | |
|---|---|---|
| committer | 2021-12-27 10:53:36 +0000 | |
| commit | cdab76406fbeb6c74a403ea640b2209ea02eb86c (patch) | |
| tree | be099b1338e10d3144188c6f5fd60b11a4817e0f /src/modules | |
| parent | Make all extensibles use kebab-case for names where possible. (diff) | |
| parent | Fix not being able to look up hostnames that point to multiple IPs. (diff) | |
Merge branch 'insp3' into master.
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/m_spanningtree/main.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/resolvers.cpp | 47 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/resolvers.h | 1 | ||||
| -rw-r--r-- | src/modules/m_starttls.cpp | 28 |
4 files changed, 59 insertions, 19 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 93afcd237..02668d190 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -853,7 +853,7 @@ void ModuleSpanningTree::OnDecodeMetaData(Extensible* target, const std::string& // HACK: this should use automatically synced user metadata in v4. User* dest = static_cast<User*>(target); if (dest && (extname == "uniqueusername")) - dest->uniqueusername = true; + dest->uniqueusername = (extdata != "0"); } Cullable::Result ModuleSpanningTree::Cull() 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()); } diff --git a/src/modules/m_spanningtree/resolvers.h b/src/modules/m_spanningtree/resolvers.h index 1bf3ce14a..a748537be 100644 --- a/src/modules/m_spanningtree/resolvers.h +++ b/src/modules/m_spanningtree/resolvers.h @@ -41,6 +41,7 @@ class SecurityIPResolver final Module* mine; std::string host; DNS::QueryType query; + bool CheckIPv4(); public: SecurityIPResolver(Module* me, DNS::Manager* mgr, const std::string& hostname, std::shared_ptr<Link> x, DNS::QueryType qt); void OnLookupComplete(const DNS::Query *r) override; diff --git a/src/modules/m_starttls.cpp b/src/modules/m_starttls.cpp index 590da9410..116f3e792 100644 --- a/src/modules/m_starttls.cpp +++ b/src/modules/m_starttls.cpp @@ -82,19 +82,43 @@ class CommandStartTLS final } }; +class TLSCap final + : public Cap::Capability +{ + private: + dynamic_reference_nocheck<IOHookProvider>& sslref; + + bool OnList(LocalUser* user) override + { + return sslref; + } + + bool OnRequest(LocalUser* user, bool adding) override + { + return sslref; + } + + public: + TLSCap(Module* mod, dynamic_reference_nocheck<IOHookProvider>& ssl) + : Cap::Capability(mod, "tls") + , sslref(ssl) + { + } +}; + class ModuleStartTLS final : public Module { private: CommandStartTLS starttls; - Cap::Capability tls; + TLSCap tls; dynamic_reference_nocheck<IOHookProvider> ssl; public: ModuleStartTLS() : Module(VF_VENDOR, "Provides the IRCv3 tls client capability.") , starttls(this, ssl) - , tls(this, "tls") + , tls(this, ssl) , ssl(this, "ssl") { } |
