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() : command_t("VHOST", 0, 2)
35 this->source = "m_vhost.so";
38 void Handle (char **parameters, int pcnt, userrec *user)
40 for (int index = 0; index < Conf->Enumerate("vhost"); index++)
42 std::string mask = Conf->ReadValue("vhost","host",index);
43 std::string username = Conf->ReadValue("vhost","user",index);
44 std::string pass = Conf->ReadValue("vhost","pass",index);
45 if ((!strcmp(parameters[0],username.c_str())) && (!strcmp(parameters[1],pass.c_str())))
49 Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask);
50 Srv->ChangeHost(user,mask);
55 Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Invalid username or password.");
59 class ModuleVHost : public Module
66 ModuleVHost(Server* Me) : Module::Module(Me)
69 Conf = new ConfigReader;
70 mycommand = new cmd_vhost();
71 Srv->AddCommand(mycommand);
74 virtual ~ModuleVHost()
79 void Implements(char* List)
84 virtual void OnRehash(const std::string ¶meter)
87 Conf = new ConfigReader;
90 virtual Version GetVersion()
92 // returns the version number of the module to be
94 return Version(1,0,0,1,VF_VENDOR);
99 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
101 class ModuleVHostFactory : public ModuleFactory
108 ~ModuleVHostFactory()
112 virtual Module * CreateModule(Server* Me)
114 return new ModuleVHost(Me);
120 extern "C" void * init_module( void )
122 return new ModuleVHostFactory;