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 * ---------------------------------------------------
19 /* $ModDesc: Provides masking of user hostnames via traditional /VHOST command */
21 static ConfigReader* Conf;
25 class cmd_vhost : public command_t
28 cmd_vhost (InspIRCd* Instance) : command_t(Instance,"VHOST", 0, 2)
30 this->source = "m_vhost.so";
31 syntax = "<username> <password>";
34 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
36 for (int index = 0; index < Conf->Enumerate("vhost"); index++)
38 std::string mask = Conf->ReadValue("vhost","host",index);
39 std::string username = Conf->ReadValue("vhost","user",index);
40 std::string pass = Conf->ReadValue("vhost","pass",index);
41 if ((!strcmp(parameters[0],username.c_str())) && (!strcmp(parameters[1],pass.c_str())))
45 user->WriteServ("NOTICE "+std::string(user->nick)+" :Setting your VHost: " + mask);
46 user->ChangeDisplayedHost(mask.c_str());
51 user->WriteServ("NOTICE "+std::string(user->nick)+" :Invalid username or password.");
56 class ModuleVHost : public Module
63 ModuleVHost(InspIRCd* Me) : Module(Me)
66 Conf = new ConfigReader(ServerInstance);
67 mycommand = new cmd_vhost(ServerInstance);
68 ServerInstance->AddCommand(mycommand);
71 virtual ~ModuleVHost()
76 void Implements(char* List)
81 virtual void OnRehash(userrec* user, const std::string ¶meter)
84 Conf = new ConfigReader(ServerInstance);
87 virtual Version GetVersion()
89 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
94 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
96 class ModuleVHostFactory : public ModuleFactory
103 ~ModuleVHostFactory()
107 virtual Module * CreateModule(InspIRCd* Me)
109 return new ModuleVHost(Me);
115 extern "C" DllExport void * init_module( void )
117 return new ModuleVHostFactory;