1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
18 #include "socketengine.h"
19 #include "command_parse.h"
21 void FloodQuitUserHandler::Call(User* current)
23 ServerInstance->Logs->Log("USERS",DEFAULT,"Excess flood from: %s@%s", current->ident.c_str(), current->host.c_str());
24 ServerInstance->SNO->WriteToSnoMask('f',"Excess flood from: %s%s%s@%s",
25 current->registered == REG_ALL ? current->nick.c_str() : "",
26 current->registered == REG_ALL ? "!" : "", current->ident.c_str(), current->host.c_str());
27 ServerInstance->Users->QuitUser(current, "Excess flood");
29 if (current->registered != REG_ALL)
31 ZLine* zl = new ZLine(ServerInstance->Time(), 0, ServerInstance->Config->ServerName, "Flood from unregistered connection", current->GetIPString());
32 if (ServerInstance->XLines->AddLine(zl,NULL))
33 ServerInstance->XLines->ApplyLines();
40 * This function is called once a second from the mainloop.
41 * It is intended to do background checking on all the user structs, e.g.
42 * stuff like ping checks, registration timeouts, etc.
44 void InspIRCd::DoBackgroundUserStuff()
47 * loop over all local users..
49 std::vector<LocalUser*>::reverse_iterator count2 = this->Users->local_users.rbegin();
50 while (count2 != this->Users->local_users.rend())
52 LocalUser *curr = *count2;
58 if (curr->CommandFloodPenalty)
60 unsigned int rate = curr->MyClass->GetCommandRate();
61 if (curr->CommandFloodPenalty > rate)
62 curr->CommandFloodPenalty -= rate;
64 curr->CommandFloodPenalty = 0;
65 curr->eh.OnDataReady();
68 switch (curr->registered)
71 if (Time() > curr->nping)
73 // This user didn't answer the last ping, remove them
76 time_t time = this->Time() - (curr->nping - curr->MyClass->GetPingTime());
78 snprintf(message, MAXBUF, "Ping timeout: %ld second%s", (long)time, time > 1 ? "s" : "");
80 curr->nping = Time() + curr->MyClass->GetPingTime();
81 this->Users->QuitUser(curr, message);
85 curr->Write("PING :%s",this->Config->ServerName.c_str());
87 curr->nping = Time() +curr->MyClass->GetPingTime();
91 if (AllModulesReportReady(curr) && curr->dns_done)
93 /* User has sent NICK/USER, modules are okay, DNS finished. */
100 if (curr->registered != REG_ALL && (Time() > (curr->age + curr->MyClass->GetRegTimeout())))
103 * registration timeout -- didnt send USER/NICK/HOST
104 * in the time specified in their connection class.
106 this->Users->QuitUser(curr, "Registration timeout");