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(const std::string &source, bool forward) : Resolver(ServerInstance, source, forward ? DNS_QUERY_AAAA : DNS_QUERY_PTR6)
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
55 /* Command 'woot', takes no parameters and needs no special modes */
56 cmd_woot (InspIRCd* Instance) : command_t(Instance,"WOOT", 0, 0)
58 this->source = "m_testcommand.so";
61 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
63 /* We dont have to worry about deleting 'r', the core will
64 * do it for us as required.*/
67 MyV6Resolver* r = new MyV6Resolver("shake.stacken.kth.se", true);
68 ServerInstance->AddResolver(r);
69 r = new MyV6Resolver("2001:6b0:1:ea:202:a5ff:fecd:13a6", false);
70 ServerInstance->AddResolver(r);
72 catch (ModuleException& e)
74 ServerInstance->Log(DEBUG,"Danger, will robinson! There was an exception: %s",e.GetReason());
81 class ModuleTestCommand : public Module
85 ModuleTestCommand(InspIRCd* Me)
89 // Create a new command
90 newcommand = new cmd_woot(ServerInstance);
91 ServerInstance->AddCommand(newcommand);
94 void Implements(char* List)
96 List[I_OnUserJoin] = 1;
99 virtual void OnUserJoin(userrec* user, chanrec* channel)
101 /* This is an example, we do nothing here */
104 virtual ~ModuleTestCommand()
109 virtual Version GetVersion()
111 return Version(1, 0, 0, 0, VF_VENDOR, API_VERSION);
116 class ModuleTestCommandFactory : public ModuleFactory
119 ModuleTestCommandFactory()
123 ~ModuleTestCommandFactory()
127 virtual Module * CreateModule(InspIRCd* Me)
129 return new ModuleTestCommand(Me);
135 extern "C" void * init_module( void )
137 return new ModuleTestCommandFactory;