2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5 * Copyright (C) 2006-2008 Robin Burchell <robin+git@viroteck.net>
6 * Copyright (C) 2005-2007 Craig Edwards <craigedwards@brainbox.cc>
7 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
8 * Copyright (C) 2006 Craig McLure <craig@chatspike.net>
10 * This file is part of InspIRCd. InspIRCd is free software: you can
11 * redistribute it and/or modify it under the terms of the GNU General Public
12 * License as published by the Free Software Foundation, version 2.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #include "socketengine.h"
29 #include "command_parse.h"
32 * This function is called once a second from the mainloop.
33 * It is intended to do background checking on all the user structs, e.g.
34 * stuff like ping checks, registration timeouts, etc.
36 void UserManager::DoBackgroundUserStuff()
39 * loop over all local users..
41 for (LocalUserList::iterator i = local_users.begin(); i != local_users.end(); ++i)
48 if (curr->CommandFloodPenalty || curr->eh.getSendQSize())
50 unsigned int rate = curr->MyClass->GetCommandRate();
51 if (curr->CommandFloodPenalty > rate)
52 curr->CommandFloodPenalty -= rate;
54 curr->CommandFloodPenalty = 0;
55 curr->eh.OnDataReady();
58 switch (curr->registered)
61 if (ServerInstance->Time() > curr->nping)
63 // This user didn't answer the last ping, remove them
66 time_t time = ServerInstance->Time() - (curr->nping - curr->MyClass->GetPingTime());
67 const std::string message = "Ping timeout: " + ConvToStr(time) + (time == 1 ? " seconds" : " second");
68 this->QuitUser(curr, message);
72 curr->Write("PING :" + ServerInstance->Config->ServerName);
74 curr->nping = ServerInstance->Time() + curr->MyClass->GetPingTime();
78 if (AllModulesReportReady(curr))
80 /* User has sent NICK/USER, modules are okay, DNS finished. */
87 if (curr->registered != REG_ALL && (ServerInstance->Time() > (curr->age + curr->MyClass->GetRegTimeout())))
90 * registration timeout -- didnt send USER/NICK/HOST
91 * in the time specified in their connection class.
93 this->QuitUser(curr, "Registration timeout");