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 * ---------------------------------------------------
25 /* $ModDesc: Provides masking of user hostnames via traditional /VHOST command */
27 static ConfigReader *Conf;
30 class cmd_vhost : public command_t
33 cmd_vhost (InspIRCd* Instance) : command_t(Instance,"VHOST", 0, 2)
35 this->source = "m_vhost.so";
36 syntax = "<username> <password>";
39 void Handle (const char** parameters, int pcnt, userrec *user)
41 for (int index = 0; index < Conf->Enumerate("vhost"); index++)
43 std::string mask = Conf->ReadValue("vhost","host",index);
44 std::string username = Conf->ReadValue("vhost","user",index);
45 std::string pass = Conf->ReadValue("vhost","pass",index);
46 if ((!strcmp(parameters[0],username.c_str())) && (!strcmp(parameters[1],pass.c_str())))
50 user->WriteServ("NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask);
51 user->ChangeDisplayedHost(mask.c_str());
56 user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid username or password.");
60 class ModuleVHost : public Module
67 ModuleVHost(InspIRCd* Me) : Module::Module(Me)
70 Conf = new ConfigReader;
71 mycommand = new cmd_vhost(ServerInstance);
72 ServerInstance->AddCommand(mycommand);
75 virtual ~ModuleVHost()
80 void Implements(char* List)
85 virtual void OnRehash(const std::string ¶meter)
88 Conf = new ConfigReader;
91 virtual Version GetVersion()
93 // returns the version number of the module to be
95 return Version(1,0,0,1,VF_VENDOR);
100 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
102 class ModuleVHostFactory : public ModuleFactory
109 ~ModuleVHostFactory()
113 virtual Module * CreateModule(InspIRCd* Me)
115 return new ModuleVHost(Me);
121 extern "C" void * init_module( void )
123 return new ModuleVHostFactory;