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 * ---------------------------------------------------
26 /* $ModDesc: Povides a proof-of-concept test /WOOT command */
28 /** A test resolver class for IPV6
30 class MyV6Resolver : public Resolver
34 MyV6Resolver(Module* me, const std::string &source, bool forward) : Resolver(ServerInstance, source, forward ? DNS_QUERY_AAAA : DNS_QUERY_PTR6, me)
39 virtual void OnLookupComplete(const std::string &result)
41 ServerInstance->Log(DEBUG,"*** RESOLVER COMPLETED %s LOOKUP, IP IS: '%s'",fw ? "FORWARD" : "REVERSE", result.c_str());
44 virtual void OnError(ResolverError e, const std::string &errormessage)
46 ServerInstance->Log(DEBUG,"*** RESOLVER GOT ERROR: %d: %s",e,errormessage.c_str());
52 class cmd_woot : public command_t
56 /* Command 'woot', takes no parameters and needs no special modes */
57 cmd_woot (InspIRCd* Instance, Module* maker) : command_t(Instance,"WOOT", 0, 0), Creator(maker)
59 this->source = "m_testcommand.so";
62 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
64 /* We dont have to worry about deleting 'r', the core will
65 * do it for us as required.*/
68 MyV6Resolver* r = new MyV6Resolver(Creator, "shake.stacken.kth.se", true);
69 ServerInstance->AddResolver(r);
70 r = new MyV6Resolver(Creator, "2001:6b0:1:ea:202:a5ff:fecd:13a6", false);
71 ServerInstance->AddResolver(r);
73 catch (ModuleException& e)
75 ServerInstance->Log(DEBUG,"Danger, will robinson! There was an exception: %s",e.GetReason());
82 class ModuleTestCommand : public Module
86 ModuleTestCommand(InspIRCd* Me)
90 // Create a new command
91 newcommand = new cmd_woot(ServerInstance, this);
92 ServerInstance->AddCommand(newcommand);
95 void Implements(char* List)
97 List[I_OnUserJoin] = 1;
100 virtual void OnUserJoin(userrec* user, chanrec* channel)
102 /* This is an example, we do nothing here */
105 virtual ~ModuleTestCommand()
110 virtual Version GetVersion()
112 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
117 class ModuleTestCommandFactory : public ModuleFactory
120 ModuleTestCommandFactory()
124 ~ModuleTestCommandFactory()
128 virtual Module * CreateModule(InspIRCd* Me)
130 return new ModuleTestCommand(Me);
136 extern "C" void * init_module( void )
138 return new ModuleTestCommandFactory;