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;
31 class cmd_vhost : public command_t
34 cmd_vhost (InspIRCd* Instance) : command_t(Instance,"VHOST", 0, 2)
36 this->source = "m_vhost.so";
37 syntax = "<username> <password>";
40 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
42 for (int index = 0; index < Conf->Enumerate("vhost"); index++)
44 std::string mask = Conf->ReadValue("vhost","host",index);
45 std::string username = Conf->ReadValue("vhost","user",index);
46 std::string pass = Conf->ReadValue("vhost","pass",index);
47 if ((!strcmp(parameters[0],username.c_str())) && (!strcmp(parameters[1],pass.c_str())))
51 user->WriteServ("NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask);
52 user->ChangeDisplayedHost(mask.c_str());
57 user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid username or password.");
62 class ModuleVHost : public Module
69 ModuleVHost(InspIRCd* Me) : Module::Module(Me)
72 Conf = new ConfigReader(ServerInstance);
73 mycommand = new cmd_vhost(ServerInstance);
74 ServerInstance->AddCommand(mycommand);
77 virtual ~ModuleVHost()
82 void Implements(char* List)
87 virtual void OnRehash(const std::string ¶meter)
90 Conf = new ConfigReader(ServerInstance);
93 virtual Version GetVersion()
95 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
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;