]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/modules/dns.h
Fix various documentation comments.
[user/henk/code/inspircd.git] / include / modules / dns.h
index 1ba54cc616375fcfed8d4d26b75b25607b617d77..5b1c426cd5e6644af9af0f6f0a3ae438996473c2 100644 (file)
@@ -1,8 +1,9 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2013 Adam <Adam@anope.org>
- *   Copyright (C) 2003-2013 Anope Team <team@anope.org>
+ *   Copyright (C) 2017, 2019, 2021 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2014-2015 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2013, 2015-2016 Adam <Adam@anope.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -33,6 +34,8 @@ namespace DNS
                QUERY_CNAME = 5,
                /* Reverse DNS lookup */
                QUERY_PTR = 12,
+               /* TXT */
+               QUERY_TXT = 16,
                /* IPv6 AAAA lookup */
                QUERY_AAAA = 28
        };
@@ -54,6 +57,7 @@ namespace DNS
        enum Error
        {
                ERROR_NONE,
+               ERROR_DISABLED,
                ERROR_UNKNOWN,
                ERROR_UNLOADED,
                ERROR_TIMEDOUT,
@@ -117,6 +121,18 @@ namespace DNS
 
                Query() : error(ERROR_NONE), cached(false) { }
                Query(const Question& q) : question(q), error(ERROR_NONE), cached(false) { }
+
+               const ResourceRecord* FindAnswerOfType(QueryType qtype) const
+               {
+                       for (std::vector<DNS::ResourceRecord>::const_iterator i = answers.begin(); i != answers.end(); ++i)
+                       {
+                               const DNS::ResourceRecord& rr = *i;
+                               if (rr.type == qtype)
+                                       return &rr;
+                       }
+
+                       return NULL;
+               }
        };
 
        class ReplySocket;
@@ -132,15 +148,17 @@ namespace DNS
                virtual void Process(Request* req) = 0;
                virtual void RemoveRequest(Request* req) = 0;
                virtual std::string GetErrorStr(Error) = 0;
+               virtual std::string GetTypeStr(QueryType) = 0;
        };
 
        /** A DNS query.
         */
-       class Request : public Timer, public Question
+       class Request : public Timer
        {
         protected:
                Manager* const manager;
         public:
+               Question question;
                /* Use result cache if available */
                bool use_cache;
                /* Request id */
@@ -149,9 +167,9 @@ namespace DNS
                Module* const creator;
 
                Request(Manager* mgr, Module* mod, const std::string& addr, QueryType qt, bool usecache = true)
-                       : Timer((ServerInstance->Config->dns_timeout ? ServerInstance->Config->dns_timeout : 5))
-                       , Question(addr, qt)
+                       : Timer(ServerInstance->Config->ConfValue("dns")->getDuration("timeout", 5, 1))
                        , manager(mgr)
+                       , question(addr, qt)
                        , use_cache(usecache)
                        , id(0)
                        , creator(mod)
@@ -164,21 +182,21 @@ namespace DNS
                }
 
                /** Called when this request succeeds
-                * @param r The query sent back from the nameserver
+                * @param req The query sent back from the nameserver
                 */
                virtual void OnLookupComplete(const Query* req) = 0;
 
                /** Called when this request fails or times out.
-                * @param r The query sent back from the nameserver, check the error code.
+                * @param req The query sent back from the nameserver, check the error code.
                 */
                virtual void OnError(const Query* req) { }
 
                /** Used to time out the query, calls OnError and asks the TimerManager
                 * to delete this request
                 */
-               bool Tick(time_t now)
+               bool Tick(time_t now) CXX11_OVERRIDE
                {
-                       Query rr(*this);
+                       Query rr(this->question);
                        rr.error = ERROR_TIMEDOUT;
                        this->OnError(&rr);
                        delete this;