summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-12 12:26:58 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-12 12:26:58 +0000
commit069fa0a4727139c4df17b1112b4d70e6b4f53433 (patch)
treef4c28304abcd42d89659e996b3f47842e0e7f1be /src
parentb864f69ce98841fd54e2328b49e34b5be49525b8 (diff)
Test framework in m_testcommand, add interface
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4354 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules.cpp6
-rw-r--r--src/modules/m_testcommand.cpp35
2 files changed, 26 insertions, 15 deletions
diff --git a/src/modules.cpp b/src/modules.cpp
index 2297db53b..7214a9673 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -43,6 +43,7 @@
#include "typedefs.h"
#include "modules.h"
#include "command_parse.h"
+#include "dns.h"
extern ServerConfig *Config;
extern InspIRCd* ServerInstance;
@@ -606,6 +607,11 @@ bool Server::DelModeWatcher(ModeWatcher* mw)
return ServerInstance->ModeGrok->DelModeWatcher(mw);
}
+bool Server::AddResolver(Resolver* r)
+{
+ return dns_add_class(r);
+}
+
int Server::CountUsers(chanrec* c)
{
return usercount(c);
diff --git a/src/modules/m_testcommand.cpp b/src/modules/m_testcommand.cpp
index 473f2941d..c194811ec 100644
--- a/src/modules/m_testcommand.cpp
+++ b/src/modules/m_testcommand.cpp
@@ -20,9 +20,25 @@ using namespace std;
#include "users.h"
#include "channels.h"
#include "modules.h"
+#include "dns.h"
/* $ModDesc: Povides a proof-of-concept test /WOOT command */
+class MyResolver : public Resolver
+{
+ MyResolver(const std::string &source, bool forward, const std::string &dnsserver = "") : Resolver(source, forward, dnsserver) { }
+
+ virtual void OnLookupComplete(const std::string &result)
+ {
+ log(DEBUG,"*** RESOLVER COMPLETED LOOKUP, IP IS: '%s'",result.c_str());
+ }
+
+ virtual void OnError(ResolverError e)
+ {
+ log(DEBUG,"*** RESOLVER GOT ERROR: %d",e);
+ }
+};
+
static Server *Srv;
class cmd_woot : public command_t
@@ -35,21 +51,10 @@ class cmd_woot : public command_t
void Handle (char **parameters, int pcnt, userrec *user)
{
- Srv->Log(DEBUG,"woot handler");
- // Here is a sample of how to send servermodes. Note that unless remote
- // servers in your net are u:lined, they may reverse this, but its a
- // quick and effective modehack.
-
- // NOTE: DO NOT CODE LIKE THIS!!! This has no checks and can send
- // invalid or plain confusing mode changes, code some checking!
- char* modes[3];
- modes[0] = "#chatspike";
- modes[1] = "+o";
- modes[2] = user->nick;
-
- // run the mode change, send numerics (such as "no such channel") back
- // to "user".
- Srv->SendMode(modes,3,user);
+ /* We dont have to worry about deleting 'r', the core will
+ * do it for us as required.*/
+ MyResolver* r = new MyResolver("brainbox.ath.cx", true);
+ Srv->AddResolver(r);
}
};