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 CHGHOST command */
26 class cmd_chghost : public command_t
31 cmd_chghost (InspIRCd* Instance, char* hmap) : command_t(Instance,"CHGHOST",'o',2), hostmap(hmap)
33 this->source = "m_chghost.so";
34 syntax = "<nick> <newhost>";
37 CmdResult Handle(const char** parameters, int pcnt, userrec *user)
39 const char * x = parameters[1];
43 if (!hostmap[(unsigned char)*x])
45 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
49 if ((parameters[1] - x) > 63)
51 user->WriteServ("NOTICE %s :*** CHGHOST: Host too long",user->nick);
54 userrec* dest = ServerInstance->FindNick(parameters[0]);
58 /* Drop it like a hot potato. XXX - we should probably message here.. -- w00t */
62 if ((dest->ChangeDisplayedHost(parameters[1])) && (!ServerInstance->ULine(user->server)))
64 // fix by brain - ulines set hosts silently
65 ServerInstance->WriteOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+dest->nick+" become "+dest->dhost);
75 class ModuleChgHost : public Module
77 cmd_chghost* mycommand;
80 ModuleChgHost(InspIRCd* Me)
84 mycommand = new cmd_chghost(ServerInstance, hostmap);
85 ServerInstance->AddCommand(mycommand);
88 void Implements(char* List)
93 void OnRehash(userrec* user, const std::string ¶meter)
95 ConfigReader Conf(ServerInstance);
96 std::string hmap = Conf.ReadValue("hostname", "charmap", 0);
99 hmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789";
101 memset(&hostmap, 0, 255);
102 for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
103 hostmap[(unsigned char)*n] = 1;
112 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
118 class ModuleChgHostFactory : public ModuleFactory
121 ModuleChgHostFactory()
125 ~ModuleChgHostFactory()
129 virtual Module * CreateModule(InspIRCd* Me)
131 return new ModuleChgHost(Me);
137 extern "C" void * init_module( void )
139 return new ModuleChgHostFactory;