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 SETHOST command */
20 class CommandSethost : public Command
25 CommandSethost (InspIRCd* Instance, char* hmap) : Command(Instance,"SETHOST",'o',1), hostmap(hmap)
27 this->source = "m_sethost.so";
28 syntax = "<new-hostname>";
29 TRANSLATE2(TR_TEXT, TR_END);
32 CmdResult Handle (const char** parameters, int pcnt, User *user)
35 for (const char* x = parameters[0]; *x; x++, len++)
37 if (!hostmap[(unsigned char)*x])
39 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** SETHOST: Invalid characters in hostname");
45 user->WriteServ("NOTICE %s :*** SETHOST: Host must be specified", user->nick);
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 CommandSethost* mycommand;
69 ModuleSetHost(InspIRCd* Me)
73 mycommand = new CommandSethost(ServerInstance, hostmap);
74 ServerInstance->AddCommand(mycommand);
75 Implementation eventlist[] = { I_OnRehash };
76 ServerInstance->Modules->Attach(eventlist, this, 1);
80 void OnRehash(User* user, const std::string ¶meter)
82 ConfigReader Conf(ServerInstance);
83 std::string hmap = Conf.ReadValue("hostname", "charmap", 0);
86 hmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789";
88 memset(&hostmap, 0, 255);
89 for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
90 hostmap[(unsigned char)*n] = 1;
93 virtual ~ModuleSetHost()
97 virtual Version GetVersion()
99 return Version(1, 1, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
104 MODULE_INIT(ModuleSetHost)