2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2017-2018 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;
39 flags_needed = 'o'; syntax = "<host>";
42 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
44 if (parameters[0].length() > ServerInstance->Config->Limits.MaxHost)
46 user->WriteNotice("*** SETHOST: Host too long");
50 for (std::string::const_iterator x = parameters[0].begin(); x != parameters[0].end(); x++)
52 if (!hostmap.test(static_cast<unsigned char>(*x)))
54 user->WriteNotice("*** SETHOST: Invalid characters in hostname");
59 if (user->ChangeDisplayedHost(parameters[0]))
61 ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used SETHOST to change their displayed host to "+user->GetDisplayedHost());
70 class ModuleSetHost : public Module
80 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
82 std::string hmap = ServerInstance->Config->ConfValue("hostname")->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789");
85 for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
86 cmd.hostmap.set(static_cast<unsigned char>(*n));
89 Version GetVersion() CXX11_OVERRIDE
91 return Version("Provides the SETHOST command", VF_VENDOR);
95 MODULE_INIT(ModuleSetHost)