2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5 * Copyright (C) 2008 Pippijn van Steenhoven <pip88nl@gmail.com>
6 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
7 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
8 * Copyright (C) 2006-2007 Oliver Lupton <oliverlupton@gmail.com>
9 * Copyright (C) 2006 Craig Edwards <craigedwards@brainbox.cc>
11 * This file is part of InspIRCd. InspIRCd is free software: you can
12 * redistribute it and/or modify it under the terms of the GNU General Public
13 * License as published by the Free Software Foundation, version 2.
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 class ModuleWaitPong : public Module
35 : ext("waitpong_pingstr", ExtensionItem::EXT_USER, this)
39 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
41 ConfigTag* tag = ServerInstance->Config->ConfValue("waitpong");
42 sendsnotice = tag->getBool("sendsnotice", true);
43 killonbadreply = tag->getBool("killonbadreply", true);
46 ModResult OnUserRegister(LocalUser* user) CXX11_OVERRIDE
48 std::string pingrpl = ServerInstance->GenRandomStr(10);
50 ClientProtocol::Messages::Ping pingmsg(pingrpl);
51 user->Send(ServerInstance->GetRFCEvents().ping, pingmsg);
55 user->WriteNotice("*** If you are having problems connecting due to ping timeouts, please type /quote PONG " + pingrpl + " or /raw PONG " + pingrpl + " now.");
57 ext.set(user, pingrpl);
58 return MOD_RES_PASSTHRU;
61 ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
63 if (command == "PONG")
65 std::string* pingrpl = ext.get(user);
69 if (!parameters.empty() && *pingrpl == parameters[0])
77 ServerInstance->Users->QuitUser(user, "Incorrect ping reply for registration");
82 return MOD_RES_PASSTHRU;
85 ModResult OnCheckReady(LocalUser* user) CXX11_OVERRIDE
87 return ext.get(user) ? MOD_RES_DENY : MOD_RES_PASSTHRU;
90 Version GetVersion() CXX11_OVERRIDE
92 return Version("Require pong prior to registration", VF_VENDOR);
96 MODULE_INIT(ModuleWaitPong)