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 * ---------------------------------------------------
22 /* $ModDesc: Provides support for the SETHOST command */
26 class cmd_sethost : public command_t
31 cmd_sethost (InspIRCd* Instance, char*& hmap) : command_t(Instance,"SETHOST",'o',1), hostmap(hmap)
33 this->source = "m_sethost.so";
34 syntax = "<new-hostname>";
37 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
40 for (const char* x = parameters[0]; *x; x++, len++)
42 if (!strchr(hostmap, *x))
44 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
50 user->WriteServ("NOTICE %s :*** SETHOST: Host too long",user->nick);
53 if (user->ChangeDisplayedHost(parameters[0]))
55 ServerInstance->WriteOpers(std::string(user->nick)+" used SETHOST to change their displayed host to "+user->dhost);
64 class ModuleSetHost : public Module
66 cmd_sethost* mycommand;
70 ModuleSetHost(InspIRCd* Me)
74 mycommand = new cmd_sethost(ServerInstance, hostmap);
75 ServerInstance->AddCommand(mycommand);
78 void Implements(char* List)
83 void OnRehash(const std::string ¶meter)
85 ConfigReader Conf(ServerInstance);
86 hmap = Conf.ReadValue("hostname", "charmap", 0);
89 hostmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789";
91 hostmap = (char*)hmap.c_str();
94 virtual ~ModuleSetHost()
98 virtual Version GetVersion()
100 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
105 class ModuleSetHostFactory : public ModuleFactory
108 ModuleSetHostFactory()
112 ~ModuleSetHostFactory()
116 virtual Module * CreateModule(InspIRCd* Me)
118 return new ModuleSetHost(Me);
124 extern "C" void * init_module( void )
126 return new ModuleSetHostFactory;