summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/dns.h1
-rw-r--r--src/dns.cpp9
-rw-r--r--src/dnsqueue.cpp19
3 files changed, 12 insertions, 17 deletions
diff --git a/include/dns.h b/include/dns.h
index 1b8c740ed..bdc7326bf 100644
--- a/include/dns.h
+++ b/include/dns.h
@@ -89,6 +89,7 @@ public:
* query is invalid for some reason, e.g. the dns server not responding.
*/
int GetFD();
+ void SetNS(std::string dnsserver);
};
#endif
diff --git a/src/dns.cpp b/src/dns.cpp
index 30d05e2a3..13a80311a 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -188,11 +188,7 @@ void DNS::dns_init_2(const char* dnsserver) { /* populates servers4 struct with
int i;
in_addr addr4;
char buf[1024];
- if (initdone == 1)
- return;
i4 = 0;
-
- initdone = 1;
srand((unsigned int) TIME);
memset(servers4,'\0',sizeof(in_addr) * DNS_MAX);
if (dns_aton4_s(dnsserver,&addr4) != NULL)
@@ -686,6 +682,11 @@ DNS::DNS(std::string dnsserver)
dns_init_2(dnsserver.c_str());
}
+void DNS::SetNS(std::string dnsserver)
+{
+ dns_init_2(dnsserver.c_str());
+}
+
DNS::~DNS()
{
}
diff --git a/src/dnsqueue.cpp b/src/dnsqueue.cpp
index e2230b584..e949ddab9 100644
--- a/src/dnsqueue.cpp
+++ b/src/dnsqueue.cpp
@@ -168,28 +168,21 @@ extern time_t TIME;
class Lookup {
private:
- DNS* resolver;
+ DNS resolver;
char u[NICKMAX];
public:
Lookup()
{
strcpy(u,"");
- resolver = NULL;
}
void Reset()
{
strcpy(u,"");
- if (resolver)
- delete resolver;
- resolver = NULL;
}
~Lookup()
{
- if (resolver)
- delete resolver;
- resolver = NULL;
}
bool DoLookup(std::string nick)
@@ -198,8 +191,8 @@ public:
if (usr)
{
log(DEBUG,"New Lookup class for %s with DNSServer set to '%s'",nick.c_str(),DNSServer);
- resolver = new DNS(std::string(DNSServer));
- if (!resolver->ReverseLookup(std::string(usr->host)))
+ resolver.SetNS(std::string(DNSServer));
+ if (!resolver.ReverseLookup(std::string(usr->host)))
return false;
strlcpy(u,nick.c_str(),NICKMAX);
return true;
@@ -210,11 +203,11 @@ public:
bool Done()
{
userrec* usr = NULL;
- if (resolver->HasResult())
+ if (resolver.HasResult())
{
- if (resolver->GetFD() != 0)
+ if (resolver.GetFD() != 0)
{
- std::string hostname = resolver->GetResult();
+ std::string hostname = resolver.GetResult();
usr = Find(u);
if (usr)
{