]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/dns.cpp
Moved some other stuff into ServerConfig
[user/henk/code/inspircd.git] / src / dns.cpp
index 0fd8b56024a7d6b8e3b17a122762a182093f0075..5a70bb41de88926a0c0c5f2ac8c82ee2612ddd82 100644 (file)
@@ -40,8 +40,8 @@ using namespace std;
 #include "socketengine.h"
 
 extern SocketEngine* SE;
-
-extern int statsAccept,statsRefused,statsUnknown,statsCollisions,statsDns,statsDnsGood,statsDnsBad,statsConnects,statsSent,statsRecv;
+extern ServerConfig* Config;
+serverstats* stats;
 
 #define max(a,b) (a > b ? a : b)
 #define DNS_MAX              8                    /* max number of nameservers used */
@@ -655,7 +655,7 @@ DNS::~DNS()
 
 bool DNS::ReverseLookup(std::string ip)
 {
-       statsDns++;
+       stats->statsDns++;
         binip = dns_aton4(ip.c_str());
         if (binip == NULL) {
                 return false;
@@ -675,7 +675,7 @@ bool DNS::ReverseLookup(std::string ip)
 
 bool DNS::ForwardLookup(std::string host)
 {
-       statsDns++;
+       stats->statsDns++;
        this->myfd = dns_getip4(host.c_str());
        if (this->myfd == -1)
        {
@@ -693,6 +693,10 @@ bool DNS::HasResult(int fd)
        return (fd == this->myfd);
 }
 
+/* Only the multithreaded dns uses this poll() based
+ * check now. As its in another thread we dont have
+ * to worry about its performance that much.
+ */
 bool DNS::HasResult()
 {
        log(DEBUG,"DNS: HasResult, fd=%d",this->myfd);
@@ -717,11 +721,11 @@ std::string DNS::GetResult()
        SE->DelFd(this->myfd);
 #endif
         if (result) {
-               statsDnsGood++;
+               stats->statsDnsGood++;
                dns_close(this->myfd);
                return result;
         } else {
-               statsDnsBad++;
+               stats->statsDnsBad++;
                if (this->myfd != -1)
                {
                        dns_close(this->myfd);
@@ -744,7 +748,7 @@ std::string DNS::GetResultIP()
        }
        if (result)
        {
-               statsDnsGood++;
+               stats->statsDnsGood++;
                unsigned char a = (unsigned)result[0];
                unsigned char b = (unsigned)result[1];
                unsigned char c = (unsigned)result[2];
@@ -754,7 +758,7 @@ std::string DNS::GetResultIP()
        }
        else
        {
-               statsDnsBad++;
+               stats->statsDnsBad++;
                log(DEBUG,"DANGER WILL ROBINSON! NXDOMAIN for forward lookup, but we got a reverse lookup!");
                return "";
        }