diff options
Diffstat (limited to 'include/modules/dns.h')
-rw-r--r-- | include/modules/dns.h | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/include/modules/dns.h b/include/modules/dns.h index 7e8de8d8a..61a23caec 100644 --- a/include/modules/dns.h +++ b/include/modules/dns.h @@ -1,12 +1,20 @@ /* + * Anope IRC Services * - * (C) 2003-2017 Anope Team - * Contact us at team@anope.org + * Copyright (C) 2012-2017 Anope Team <team@anope.org> * - * Please read COPYING and README for further details. + * This file is part of Anope. Anope is free software; you can + * redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software + * Foundation, version 2. * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see see <http://www.gnu.org/licenses/>. */ #ifndef DNS_H @@ -117,17 +125,19 @@ namespace DNS class Manager : public Service { public: - Manager(Module *creator) : Service(creator, "DNS::Manager", "dns/manager") { } + static constexpr const char *NAME = "dns/manager"; + + Manager(Module *creator) : Service(creator, NAME) { } virtual ~Manager() { } - virtual void Process(Request *req) = 0; - virtual void RemoveRequest(Request *req) = 0; + virtual void Process(Request *req) anope_abstract; + virtual void RemoveRequest(Request *req) anope_abstract; - virtual bool HandlePacket(ReplySocket *s, const unsigned char *const data, int len, sockaddrs *from) = 0; + virtual bool HandlePacket(ReplySocket *s, const unsigned char *const data, int len, sockaddrs *from) anope_abstract; - virtual void UpdateSerial() = 0; - virtual void Notify(const Anope::string &zone) = 0; - virtual uint32_t GetSerial() const = 0; + virtual void UpdateSerial() anope_abstract; + virtual void Notify(const Anope::string &zone) anope_abstract; + virtual uint32_t GetSerial() const anope_abstract; }; /** A DNS query. @@ -154,7 +164,7 @@ namespace DNS /** Called when this request succeeds * @param r The query sent back from the nameserver */ - virtual void OnLookupComplete(const Query *r) = 0; + virtual void OnLookupComplete(const Query *r) anope_abstract; /** Called when this request fails or times out. * @param r The query sent back from the nameserver, check the error code. @@ -164,9 +174,9 @@ namespace DNS /** Used to time out the query, xalls OnError and lets the TimerManager * delete this request. */ - void Tick(time_t) anope_override + void Tick(time_t) override { - Log(LOG_DEBUG_2) << "Resolver: timeout for query " << this->name; + Anope::Logger.Debug2("Resolver: timeout for query {0}", this->name); Query rr(*this); rr.error = ERROR_TIMEDOUT; this->OnError(&rr); @@ -175,4 +185,22 @@ namespace DNS } // namespace DNS +namespace Event +{ + struct CoreExport DnsRequest : Events + { + static constexpr const char *NAME = "dnsrequest"; + + using Events::Events; + + /** Called when a DNS request (question) is recieved. + * @param req The dns request + * @param reply The reply that will be sent + */ + virtual void OnDnsRequest(DNS::Query &req, DNS::Query *reply) anope_abstract; + }; +} + #endif // DNS_H + + |