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/>.
26 #include "socketengine.h"
27 #include "command_parse.h"
30 * This function is called once a second from the mainloop.
31 * It is intended to do background checking on all the user structs, e.g.
32 * stuff like ping checks, registration timeouts, etc.
34 void UserManager::DoBackgroundUserStuff()
37 * loop over all local users..
39 for (LocalUserList::iterator i = local_users.begin(); i != local_users.end(); ++i)
46 if (curr->CommandFloodPenalty || curr->eh.getSendQSize())
48 unsigned int rate = curr->MyClass->GetCommandRate();
49 if (curr->CommandFloodPenalty > rate)
50 curr->CommandFloodPenalty -= rate;
52 curr->CommandFloodPenalty = 0;
53 curr->eh.OnDataReady();
56 switch (curr->registered)
59 if (ServerInstance->Time() > curr->nping)
61 // This user didn't answer the last ping, remove them
64 time_t time = ServerInstance->Time() - (curr->nping - curr->MyClass->GetPingTime());
65 const std::string message = "Ping timeout: " + ConvToStr(time) + (time == 1 ? " seconds" : " second");
66 this->QuitUser(curr, message);
70 curr->Write("PING :" + ServerInstance->Config->ServerName);
72 curr->nping = ServerInstance->Time() + curr->MyClass->GetPingTime();
76 if (AllModulesReportReady(curr))
78 /* User has sent NICK/USER, modules are okay, DNS finished. */
85 if (curr->registered != REG_ALL && (ServerInstance->Time() > (curr->age + curr->MyClass->GetRegTimeout())))
88 * registration timeout -- didnt send USER/NICK/HOST
89 * in the time specified in their connection class.
91 this->QuitUser(curr, "Registration timeout");