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 support for the CHGHOST command */
23 class cmd_chghost : public command_t
28 cmd_chghost (InspIRCd* Instance, char* hmap) : command_t(Instance,"CHGHOST",'o',2), hostmap(hmap)
30 this->source = "m_chghost.so";
31 syntax = "<nick> <newhost>";
34 CmdResult Handle(const char** parameters, int pcnt, userrec *user)
36 const char * x = parameters[1];
40 if (!hostmap[(unsigned char)*x])
42 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** CHGHOST: Invalid characters in hostname");
48 user->WriteServ("NOTICE %s :*** CHGHOST: Host must be specified", user->nick);
52 if ((parameters[1] - x) > 63)
54 user->WriteServ("NOTICE %s :*** CHGHOST: Host too long", user->nick);
57 userrec* dest = ServerInstance->FindNick(parameters[0]);
61 user->WriteServ("401 %s %s :No such nick/channel", user->nick, parameters[0]);
65 if ((dest->ChangeDisplayedHost(parameters[1])) && (!ServerInstance->ULine(user->server)))
67 // fix by brain - ulines set hosts silently
68 ServerInstance->WriteOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+dest->nick+" become "+dest->dhost);
78 class ModuleChgHost : public Module
80 cmd_chghost* mycommand;
83 ModuleChgHost(InspIRCd* Me)
87 mycommand = new cmd_chghost(ServerInstance, hostmap);
88 ServerInstance->AddCommand(mycommand);
91 void Implements(char* List)
96 void OnRehash(userrec* user, const std::string ¶meter)
98 ConfigReader Conf(ServerInstance);
99 std::string hmap = Conf.ReadValue("hostname", "charmap", 0);
102 hmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789";
104 memset(&hostmap, 0, 255);
105 for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
106 hostmap[(unsigned char)*n] = 1;
115 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
120 MODULE_INIT(ModuleChgHost)