summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-07 21:16:03 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-01-07 21:16:03 +0000
commitdac672cf303ce44dc5f877a5f9f7e5aee64b95e1 (patch)
tree3484e7870d732dd04a590640cfe5c72ea50e7dde /src/modules
parent6b9eaeba4130acb818a63782640194c7e5bcc2fa (diff)
DNS Stuff - this wont work right yet, it will soon (tm)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6250 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/extra/m_pgsql.cpp13
-rw-r--r--src/modules/m_cgiirc.cpp20
-rw-r--r--src/modules/m_dnsbl.cpp12
-rw-r--r--src/modules/m_http_client.cpp9
-rw-r--r--src/modules/m_spanningtree.cpp20
-rw-r--r--src/modules/m_testcommand.cpp24
6 files changed, 70 insertions, 28 deletions
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp
index 79630d416..d72256a5f 100644
--- a/src/modules/extra/m_pgsql.cpp
+++ b/src/modules/extra/m_pgsql.cpp
@@ -90,8 +90,8 @@ class SQLresolver : public Resolver
SQLhost host;
Module* mod;
public:
- SQLresolver(Module* m, InspIRCd* Instance, const SQLhost& hi)
- : Resolver(Instance, hi.host, DNS_QUERY_FORWARD, (Module*)m), host(hi), mod(m)
+ SQLresolver(Module* m, InspIRCd* Instance, const SQLhost& hi, bool &cached)
+ : Resolver(Instance, hi.host, DNS_QUERY_FORWARD, cached, (Module*)m), host(hi), mod(m)
{
}
@@ -1099,9 +1099,12 @@ public:
try
{
- resolver = new SQLresolver(this, ServerInstance, host);
-
- ServerInstance->AddResolver(resolver);
+ bool cached;
+ resolver = new SQLresolver(this, ServerInstance, host, cached);
+ if (!cached)
+ ServerInstance->AddResolver(resolver);
+ else
+ delete resolver;
}
catch(...)
{
diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp
index dc11ccf96..6df039dce 100644
--- a/src/modules/m_cgiirc.cpp
+++ b/src/modules/m_cgiirc.cpp
@@ -51,8 +51,8 @@ class CGIResolver : public Resolver
userrec* them;
bool notify;
public:
- CGIResolver(Module* me, InspIRCd* ServerInstance, bool NotifyOpers, const std::string &source, bool forward, userrec* u, int userfd, const std::string &type)
- : Resolver(ServerInstance, source, forward ? DNS_QUERY_FORWARD : DNS_QUERY_REVERSE, me), typ(type), theirfd(userfd), them(u), notify(NotifyOpers) { }
+ CGIResolver(Module* me, InspIRCd* ServerInstance, bool NotifyOpers, const std::string &source, bool forward, userrec* u, int userfd, const std::string &type, bool &cached)
+ : Resolver(ServerInstance, source, forward ? DNS_QUERY_FORWARD : DNS_QUERY_REVERSE, cached, me), typ(type), theirfd(userfd), them(u), notify(NotifyOpers) { }
virtual void OnLookupComplete(const std::string &result, unsigned int ttl)
{
@@ -259,8 +259,12 @@ public:
try
{
- CGIResolver* r = new CGIResolver(this, ServerInstance, NotifyOpers, user->password, false, user, user->GetFd(), "PASS");
- ServerInstance->AddResolver(r);
+ bool cached;
+ CGIResolver* r = new CGIResolver(this, ServerInstance, NotifyOpers, user->password, false, user, user->GetFd(), "PASS", cached);
+ if (!cached)
+ ServerInstance->AddResolver(r);
+ else
+ delete r;
}
catch (ModuleException& e)
{
@@ -315,8 +319,12 @@ public:
try
{
ServerInstance->Log(DEBUG,"MAKE RESOLVER: %s %d %s",newip, user->GetFd(), "IDENT");
- CGIResolver* r = new CGIResolver(this, ServerInstance, NotifyOpers, newip, false, user, user->GetFd(), "IDENT");
- ServerInstance->AddResolver(r);
+ bool cached;
+ CGIResolver* r = new CGIResolver(this, ServerInstance, NotifyOpers, newip, false, user, user->GetFd(), "IDENT", cached);
+ if (!cached)
+ ServerInstance->AddResolver(r);
+ else
+ delete r;
}
catch (ModuleException& e)
{
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp
index 91bfa5131..d6581a7d1 100644
--- a/src/modules/m_dnsbl.cpp
+++ b/src/modules/m_dnsbl.cpp
@@ -46,8 +46,8 @@ class DNSBLResolver : public Resolver
DNSBLConfEntry *ConfEntry;
public:
- DNSBLResolver(Module *me, InspIRCd *ServerInstance, const std::string &hostname, userrec* u, int userfd, DNSBLConfEntry *conf)
- : Resolver(ServerInstance, hostname, DNS_QUERY_A, me)
+ DNSBLResolver(Module *me, InspIRCd *ServerInstance, const std::string &hostname, userrec* u, int userfd, DNSBLConfEntry *conf, bool &cached)
+ : Resolver(ServerInstance, hostname, DNS_QUERY_A, cached, me)
{
theirfd = userfd;
them = u;
@@ -307,8 +307,12 @@ class ModuleDNSBL : public Module
ServerInstance->Log(DEBUG, "m_dnsbl: sending %s for resolution", hostname.c_str());
/* now we'd need to fire off lookups for `hostname'. */
- DNSBLResolver *r = new DNSBLResolver(this, ServerInstance, hostname, user, user->GetFd(), *i);
- ServerInstance->AddResolver(r);
+ bool cached;
+ DNSBLResolver *r = new DNSBLResolver(this, ServerInstance, hostname, user, user->GetFd(), *i, cached);
+ if (!cached)
+ ServerInstance->AddResolver(r);
+ else
+ delete r;
}
}
diff --git a/src/modules/m_http_client.cpp b/src/modules/m_http_client.cpp
index 0ca302ef6..92a9aa348 100644
--- a/src/modules/m_http_client.cpp
+++ b/src/modules/m_http_client.cpp
@@ -56,7 +56,7 @@ class HTTPResolver : public Resolver
private:
HTTPSocket *socket;
public:
- HTTPResolver(HTTPSocket *socket, InspIRCd *Instance, const string &hostname) : Resolver(Instance, hostname, DNS_QUERY_FORWARD), socket(socket)
+ HTTPResolver(HTTPSocket *socket, InspIRCd *Instance, const string &hostname, bool &cached, Module* me) : Resolver(Instance, hostname, DNS_QUERY_FORWARD, cached, me), socket(socket)
{
}
@@ -149,7 +149,12 @@ bool HTTPSocket::DoRequest(HTTPClientRequest *req)
if (!inet_aton(this->host, &this->addy))
{
- new HTTPResolver(this, Server, url.domain);
+ bool cached;
+ HTTPResolver* r = new HTTPResolver(this, Server, url.domain, cached, (Module*)Mod);
+ if (!cached)
+ Instance->AddResolver(r);
+ else
+ delete r;
return true;
}
else
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index 359196990..cbecfa24f 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -3714,7 +3714,7 @@ class ServernameResolver : public Resolver
Link MyLink;
SpanningTreeUtilities* Utils;
public:
- ServernameResolver(Module* me, SpanningTreeUtilities* Util, InspIRCd* Instance, const std::string &hostname, Link x) : Resolver(Instance, hostname, DNS_QUERY_FORWARD, me), MyLink(x), Utils(Util)
+ ServernameResolver(Module* me, SpanningTreeUtilities* Util, InspIRCd* Instance, const std::string &hostname, Link x, bool &cached) : Resolver(Instance, hostname, DNS_QUERY_FORWARD, cached, me), MyLink(x), Utils(Util)
{
/* Nothing in here, folks */
}
@@ -3764,7 +3764,7 @@ class SecurityIPResolver : public Resolver
Link MyLink;
SpanningTreeUtilities* Utils;
public:
- SecurityIPResolver(Module* me, SpanningTreeUtilities* U, InspIRCd* Instance, const std::string &hostname, Link x) : Resolver(Instance, hostname, DNS_QUERY_FORWARD, me), MyLink(x), Utils(U)
+ SecurityIPResolver(Module* me, SpanningTreeUtilities* U, InspIRCd* Instance, const std::string &hostname, Link x, bool &cached) : Resolver(Instance, hostname, DNS_QUERY_FORWARD, cached, me), MyLink(x), Utils(U)
{
}
@@ -4122,8 +4122,12 @@ void SpanningTreeUtilities::ReadConfiguration(bool rebind)
{
try
{
- SecurityIPResolver* sr = new SecurityIPResolver((Module*)this->Creator, this, ServerInstance, L.IPAddr, L);
- ServerInstance->AddResolver(sr);
+ bool cached;
+ SecurityIPResolver* sr = new SecurityIPResolver((Module*)this->Creator, this, ServerInstance, L.IPAddr, L, cached);
+ if (!cached)
+ ServerInstance->AddResolver(sr);
+ else
+ delete sr;
}
catch (ModuleException& e)
{
@@ -4653,8 +4657,12 @@ class ModuleSpanningTree : public Module
{
try
{
- ServernameResolver* snr = new ServernameResolver((Module*)this, Utils, ServerInstance,x->IPAddr, *x);
- ServerInstance->AddResolver(snr);
+ bool cached;
+ ServernameResolver* snr = new ServernameResolver((Module*)this, Utils, ServerInstance,x->IPAddr, *x, cached);
+ if (!cached)
+ ServerInstance->AddResolver(snr);
+ else
+ delete snr;
}
catch (ModuleException& e)
{
diff --git a/src/modules/m_testcommand.cpp b/src/modules/m_testcommand.cpp
index 00988ff96..55632c98e 100644
--- a/src/modules/m_testcommand.cpp
+++ b/src/modules/m_testcommand.cpp
@@ -26,7 +26,7 @@ class MyV6Resolver : public Resolver
{
bool fw;
public:
- MyV6Resolver(InspIRCd* Instance, Module* me, const std::string &source, bool forward) : Resolver(Instance, source, forward ? DNS_QUERY_AAAA : DNS_QUERY_PTR6, me)
+ MyV6Resolver(InspIRCd* Instance, Module* me, const std::string &source, bool forward, bool &cached) : Resolver(Instance, source, forward ? DNS_QUERY_AAAA : DNS_QUERY_PTR6, cached, me)
{
fw = forward;
}
@@ -60,10 +60,24 @@ class cmd_woot : public command_t
* do it for us as required.*/
try
{
- MyV6Resolver* r = new MyV6Resolver(ServerInstance, Creator, "shake.stacken.kth.se", true);
- ServerInstance->AddResolver(r);
- r = new MyV6Resolver(ServerInstance, Creator, "2001:6b0:1:ea:202:a5ff:fecd:13a6", false);
- ServerInstance->AddResolver(r);
+ bool cached1, cached2;
+ MyV6Resolver* r = new MyV6Resolver(ServerInstance, Creator, "shake.stacken.kth.se", true, cached1);
+ if (!cached1)
+ ServerInstance->AddResolver(r);
+ else
+ {
+ ServerInstance->Log(DEBUG,"Result was cached, delete object");
+ delete r;
+ }
+
+ r = new MyV6Resolver(ServerInstance, Creator, "2001:6b0:1:ea:202:a5ff:fecd:13a6", false, cached2);
+ if (!cached2)
+ ServerInstance->AddResolver(r);
+ else
+ {
+ ServerInstance->Log(DEBUG,"Result was cached, delete object");
+ delete r;
+ }
}
catch (ModuleException& e)
{