1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
20 /* $ModDesc: Provides masking of user hostnames via traditional /VHOST command */
22 static ConfigReader* Conf;
26 class cmd_vhost : public command_t
29 cmd_vhost (InspIRCd* Instance) : command_t(Instance,"VHOST", 0, 2)
31 this->source = "m_vhost.so";
32 syntax = "<username> <password>";
35 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
37 for (int index = 0; index < Conf->Enumerate("vhost"); index++)
39 std::string mask = Conf->ReadValue("vhost","host",index);
40 std::string username = Conf->ReadValue("vhost","user",index);
41 std::string pass = Conf->ReadValue("vhost","pass",index);
42 if ((!strcmp(parameters[0],username.c_str())) && (!strcmp(parameters[1],pass.c_str())))
46 user->WriteServ("NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask);
47 user->ChangeDisplayedHost(mask.c_str());
52 user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid username or password.");
57 class ModuleVHost : public Module
64 ModuleVHost(InspIRCd* Me) : Module::Module(Me)
67 Conf = new ConfigReader(ServerInstance);
68 mycommand = new cmd_vhost(ServerInstance);
69 ServerInstance->AddCommand(mycommand);
72 virtual ~ModuleVHost()
77 void Implements(char* List)
82 virtual void OnRehash(userrec* user, const std::string ¶meter)
85 Conf = new ConfigReader(ServerInstance);
88 virtual Version GetVersion()
90 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
95 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
97 class ModuleVHostFactory : public ModuleFactory
104 ~ModuleVHostFactory()
108 virtual Module * CreateModule(InspIRCd* Me)
110 return new ModuleVHost(Me);
116 extern "C" void * init_module( void )
118 return new ModuleVHostFactory;