2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2018-2019 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2012-2013, 2015, 2018 Attila Molnar <attilamolnar@hush.com>
6 * Copyright (C) 2012 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
8 * Copyright (C) 2008 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>
11 * Copyright (C) 2006 Oliver Lupton <om@inspircd.org>
13 * This file is part of InspIRCd. InspIRCd is free software: you can
14 * redistribute it and/or modify it under the terms of the GNU General Public
15 * License as published by the Free Software Foundation, version 2.
17 * This program is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 class ModuleWaitPong : public Module
37 : ext("waitpong_pingstr", ExtensionItem::EXT_USER, this)
41 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
43 ConfigTag* tag = ServerInstance->Config->ConfValue("waitpong");
44 sendsnotice = tag->getBool("sendsnotice", false);
45 killonbadreply = tag->getBool("killonbadreply", true);
48 ModResult OnUserRegister(LocalUser* user) CXX11_OVERRIDE
50 std::string pingrpl = ServerInstance->GenRandomStr(10);
52 ClientProtocol::Messages::Ping pingmsg(pingrpl);
53 user->Send(ServerInstance->GetRFCEvents().ping, pingmsg);
57 user->WriteNotice("*** If you are having problems connecting due to registration timeouts type /quote PONG " + pingrpl + " or /raw PONG " + pingrpl + " now.");
59 ext.set(user, pingrpl);
60 return MOD_RES_PASSTHRU;
63 ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
65 if (command == "PONG")
67 std::string* pingrpl = ext.get(user);
71 if (!parameters.empty() && *pingrpl == parameters[0])
79 ServerInstance->Users->QuitUser(user, "Incorrect ping reply for registration");
84 return MOD_RES_PASSTHRU;
87 ModResult OnCheckReady(LocalUser* user) CXX11_OVERRIDE
89 return ext.get(user) ? MOD_RES_DENY : MOD_RES_PASSTHRU;
92 Version GetVersion() CXX11_OVERRIDE
94 return Version("Requires all clients to respond to a PING request before they can fully connect.", VF_VENDOR);
98 MODULE_INIT(ModuleWaitPong)