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 * ---------------------------------------------------
24 /* $ModDesc: Provides masking of user hostnames via traditional /VHOST command */
29 class cmd_vhost : public command_t
32 cmd_vhost() : command_t("VHOST", 0, 2)
34 this->source = "m_vhost.so";
37 void Handle (char **parameters, int pcnt, userrec *user)
39 for (int index = 0; index < Conf->Enumerate("vhost"); index++)
41 std::string mask = Conf->ReadValue("vhost","host",index);
42 std::string username = Conf->ReadValue("vhost","user",index);
43 std::string pass = Conf->ReadValue("vhost","pass",index);
44 if ((!strcmp(parameters[0],username.c_str())) && (!strcmp(parameters[1],pass.c_str())))
48 Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask);
49 Srv->ChangeHost(user,mask);
54 Srv->SendServ(user->fd,"NOTICE "+std::string(user->nick)+" :Invalid username or password.");
58 class ModuleVHost : public Module
65 ModuleVHost(Server* 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(std::string parameter)
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;