1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
23 #include "helperfuncs.h"
26 /* $ModDesc: Povides a proof-of-concept test /WOOT command */
28 class MyV6Resolver : public Resolver
32 MyV6Resolver(const std::string &source, bool forward) : Resolver(source, forward ? DNS_QUERY_AAAA : DNS_QUERY_PTR6)
37 virtual void OnLookupComplete(const std::string &result)
39 log(DEBUG,"*** RESOLVER COMPLETED %s LOOKUP, IP IS: '%s'",fw ? "FORWARD" : "REVERSE", result.c_str());
42 virtual void OnError(ResolverError e, const std::string &errormessage)
44 log(DEBUG,"*** RESOLVER GOT ERROR: %d: %s",e,errormessage.c_str());
50 class cmd_woot : public command_t
53 cmd_woot () : command_t("WOOT", 0, 0)
55 this->source = "m_testcommand.so";
58 void Handle (const char** parameters, int pcnt, userrec *user)
60 /* We dont have to worry about deleting 'r', the core will
61 * do it for us as required.*/
65 MyV6Resolver* r = new MyV6Resolver("shake.stacken.kth.se", true);
67 r = new MyV6Resolver("2001:6b0:1:ea:202:a5ff:fecd:13a6", false);
70 catch (ModuleException& e)
72 log(DEBUG,"Danger, will robinson! There was an exception: %s",e.GetReason());
77 class ModuleTestCommand : public Module
81 ModuleTestCommand(Server* Me)
85 // Create a new command:
86 // command will be called /WOOT, and will
87 // call handle_woot when triggered, the
88 // 0 in the modes parameter signifies that
89 // anyone can issue the command, and the
90 // command takes only one parameter.
91 newcommand = new cmd_woot();
92 Srv->AddCommand(newcommand);
95 void Implements(char* List)
97 List[I_OnUserJoin] = 1;
100 virtual void OnUserJoin(userrec* user, chanrec* channel)
104 virtual ~ModuleTestCommand()
108 virtual Version GetVersion()
110 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
115 class ModuleTestCommandFactory : public ModuleFactory
118 ModuleTestCommandFactory()
122 ~ModuleTestCommandFactory()
126 virtual Module * CreateModule(Server* Me)
128 return new ModuleTestCommand(Me);
134 extern "C" void * init_module( void )
136 return new ModuleTestCommandFactory;