]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/dns.cpp
Make irc::spacify take 'const char*' instead of 'char*'
[user/henk/code/inspircd.git] / src / dns.cpp
index 3381c18fa000e3886cb7e86d6ff058f418d4410a..54032bf2ef206e6823c32f47450c1bde708b6ef2 100644 (file)
@@ -2,14 +2,11 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- *                    E-mail:
- *             <brain@chatspike.net>
- *             <Craig@chatspike.net>
- *     
- * Written by Craig Edwards, Craig McLure, and others.
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
  * This program is free but copyrighted software; see
- *         the file COPYING for details.
+ *            the file COPYING for details.
  *
  * ---------------------------------------------------
  */
@@ -24,8 +21,6 @@ Please do not assume that firedns works like this,
 looks like this, walks like this or tastes like this.
 */
 
-using namespace std;
-
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <errno.h>
@@ -37,7 +32,6 @@ using namespace std;
 #include "configreader.h"
 #include "socket.h"
 
-using namespace std;
 using irc::sockets::insp_sockaddr;
 using irc::sockets::insp_inaddr;
 using irc::sockets::insp_ntoa;
@@ -731,7 +725,11 @@ DNSInfo DNSRequest::ResultIsReady(DNSHeader &header, int length)
        int curanswer, o;
        ResourceRecord rr;
        unsigned short ptr;
-                       
+
+       /* This is just to keep _FORTIFY_SOURCE happy */
+       rr.type = DNS_QUERY_NONE;
+       rr.rdlength = 0;
+
        if (!(header.flags1 & FLAGS_MASK_QR))
                return std::make_pair((unsigned char*)NULL,"Not a query result");
 
@@ -870,7 +868,7 @@ DNS::~DNS()
 }
 
 /** High level abstraction of dns used by application at large */
-Resolver::Resolver(InspIRCd* Instance, const std::string &source, QueryType qt) : ServerInstance(Instance), input(source), querytype(qt)
+Resolver::Resolver(InspIRCd* Instance, const std::string &source, QueryType qt, Module* creator) : ServerInstance(Instance), Creator(creator), input(source), querytype(qt)
 {
        ServerInstance->Log(DEBUG,"Instance: %08x %08x",Instance, ServerInstance);
 
@@ -948,6 +946,11 @@ int Resolver::GetId()
        return this->myid;
 }
 
+Module* Resolver::GetCreator()
+{
+       return this->Creator;
+}
+
 /** Process a socket read event */
 void DNS::HandleEvent(EventType et, int errornum)
 {
@@ -1025,6 +1028,22 @@ bool DNS::AddResolverClass(Resolver* r)
        }
 }
 
+void DNS::CleanResolvers(Module* module)
+{
+       for (int i = 0; i < MAX_REQUEST_ID; i++)
+       {
+               if (Classes[i])
+               {
+                       if (Classes[i]->GetCreator() == module)
+                       {
+                               Classes[i]->OnError(RESLOVER_FORCEUNLOAD, "Parent module is unloading");
+                               delete Classes[i];
+                               Classes[i] = NULL;
+                       }
+               }
+       }
+}
+
 /** Generate pseudo-random number */
 unsigned long DNS::PRNG()
 {