2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2017-2018, 2020 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2012-2013 Attila Molnar <attilamolnar@hush.com>
6 * Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
8 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
9 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
10 * Copyright (C) 2006, 2010 Craig Edwards <brain@inspircd.org>
12 * This file is part of InspIRCd. InspIRCd is free software: you can
13 * redistribute it and/or modify it under the terms of the GNU General Public
14 * License as published by the Free Software Foundation, version 2.
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 class CommandSethost : public Command
33 std::bitset<UCHAR_MAX> hostmap;
35 CommandSethost(Module* Creator)
36 : Command(Creator,"SETHOST", 1)
38 allow_empty_last_param = false;
43 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
45 if (parameters[0].length() > ServerInstance->Config->Limits.MaxHost)
47 user->WriteNotice("*** SETHOST: Host too long");
51 for (std::string::const_iterator x = parameters[0].begin(); x != parameters[0].end(); x++)
53 if (!hostmap.test(static_cast<unsigned char>(*x)))
55 user->WriteNotice("*** SETHOST: Invalid characters in hostname");
60 if (user->ChangeDisplayedHost(parameters[0]))
62 ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used SETHOST to change their displayed host to "+user->GetDisplayedHost());
71 class ModuleSetHost : public Module
81 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
83 ConfigTag* tag = ServerInstance->Config->ConfValue("hostname");
84 const std::string hmap = tag->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789", 1);
87 for (std::string::const_iterator n = hmap.begin(); n != hmap.end(); n++)
88 cmd.hostmap.set(static_cast<unsigned char>(*n));
91 Version GetVersion() CXX11_OVERRIDE
93 return Version("Adds the /SETHOST command which allows server operators to change their displayed hostname.", VF_VENDOR);
97 MODULE_INIT(ModuleSetHost)