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 SETHOST command */
23 class cmd_sethost : public command_t
28 cmd_sethost (InspIRCd* Instance, char* hmap) : command_t(Instance,"SETHOST",'o',1), hostmap(hmap)
30 this->source = "m_sethost.so";
31 syntax = "<new-hostname>";
34 CmdResult Handle (const char** parameters, int pcnt, userrec *user)
37 for (const char* x = parameters[0]; *x; x++, len++)
39 if (!hostmap[(unsigned char)*x])
41 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** SETHOST: Invalid characters in hostname");
47 user->WriteServ("NOTICE %s :*** SETHOST: Host must be specified", user->nick);
52 user->WriteServ("NOTICE %s :*** SETHOST: Host too long",user->nick);
55 if (user->ChangeDisplayedHost(parameters[0]))
57 ServerInstance->WriteOpers(std::string(user->nick)+" used SETHOST to change their displayed host to "+user->dhost);
66 class ModuleSetHost : public Module
68 cmd_sethost* mycommand;
71 ModuleSetHost(InspIRCd* Me)
75 mycommand = new cmd_sethost(ServerInstance, hostmap);
76 ServerInstance->AddCommand(mycommand);
79 void Implements(char* List)
84 void OnRehash(userrec* user, const std::string ¶meter)
86 ConfigReader Conf(ServerInstance);
87 std::string hmap = Conf.ReadValue("hostname", "charmap", 0);
90 hmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789";
92 memset(&hostmap, 0, 255);
93 for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
94 hostmap[(unsigned char)*n] = 1;
97 virtual ~ModuleSetHost()
101 virtual Version GetVersion()
103 return Version(1, 1, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
108 MODULE_INIT(ModuleSetHost)