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 * ---------------------------------------------------
16 /* $ModDesc: Provides support for the CHGHOST command */
20 class cmd_chghost : public command_t
25 cmd_chghost (InspIRCd* Instance, char* hmap) : command_t(Instance,"CHGHOST",'o',2), hostmap(hmap)
27 this->source = "m_chghost.so";
28 syntax = "<nick> <newhost>";
29 TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
32 CmdResult Handle(const char** parameters, int pcnt, userrec *user)
34 const char * x = parameters[1];
38 if (!hostmap[(unsigned char)*x])
40 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** CHGHOST: Invalid characters in hostname");
46 user->WriteServ("NOTICE %s :*** CHGHOST: Host must be specified", user->nick);
50 if ((parameters[1] - x) > 63)
52 user->WriteServ("NOTICE %s :*** CHGHOST: Host too long", user->nick);
55 userrec* dest = ServerInstance->FindNick(parameters[0]);
59 user->WriteServ("401 %s %s :No such nick/channel", user->nick, parameters[0]);
63 if ((dest->ChangeDisplayedHost(parameters[1])) && (!ServerInstance->ULine(user->server)))
65 // fix by brain - ulines set hosts silently
66 ServerInstance->WriteOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+dest->nick+" become "+dest->dhost);
76 class ModuleChgHost : public Module
78 cmd_chghost* mycommand;
81 ModuleChgHost(InspIRCd* Me)
85 mycommand = new cmd_chghost(ServerInstance, hostmap);
86 ServerInstance->AddCommand(mycommand);
89 void Implements(char* List)
94 void OnRehash(userrec* user, const std::string ¶meter)
96 ConfigReader Conf(ServerInstance);
97 std::string hmap = Conf.ReadValue("hostname", "charmap", 0);
100 hmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789";
102 memset(&hostmap, 0, 255);
103 for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
104 hostmap[(unsigned char)*n] = 1;
113 return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
118 MODULE_INIT(ModuleChgHost)