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 * ---------------------------------------------------
27 /* $ModDesc: Povides a proof-of-concept test /WOOT command */
31 class MyV6Resolver : public Resolver
35 MyV6Resolver(const std::string &source, bool forward) : Resolver(ServerInstance, source, forward ? DNS_QUERY_AAAA : DNS_QUERY_PTR6)
40 virtual void OnLookupComplete(const std::string &result)
42 ServerInstance->Log(DEBUG,"*** RESOLVER COMPLETED %s LOOKUP, IP IS: '%s'",fw ? "FORWARD" : "REVERSE", result.c_str());
45 virtual void OnError(ResolverError e, const std::string &errormessage)
47 ServerInstance->Log(DEBUG,"*** RESOLVER GOT ERROR: %d: %s",e,errormessage.c_str());
53 class cmd_woot : public command_t
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.*/
68 MyV6Resolver* r = new MyV6Resolver("shake.stacken.kth.se", true);
69 ServerInstance->AddResolver(r);
70 r = new MyV6Resolver("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 // command will be called /WOOT, and will
92 // call handle_woot when triggered, the
93 // 0 in the modes parameter signifies that
94 // anyone can issue the command, and the
95 // command takes only one parameter.
96 newcommand = new cmd_woot(ServerInstance);
97 ServerInstance->AddCommand(newcommand);
100 void Implements(char* List)
102 List[I_OnUserJoin] = 1;
105 virtual void OnUserJoin(userrec* user, chanrec* channel)
109 virtual ~ModuleTestCommand()
113 virtual Version GetVersion()
115 return Version(1, 0, 0, 0, VF_VENDOR);
120 class ModuleTestCommandFactory : public ModuleFactory
123 ModuleTestCommandFactory()
127 ~ModuleTestCommandFactory()
131 virtual Module * CreateModule(InspIRCd* Me)
133 return new ModuleTestCommand(Me);
139 extern "C" void * init_module( void )
141 return new ModuleTestCommandFactory;