user->ForEachNeighbor(*this, false);
}
};
+
+ void CheckPingTimeout(LocalUser* user)
+ {
+ // Check if it is time to ping the user yet.
+ if (ServerInstance->Time() < user->nextping)
+ return;
+
+ // This user didn't answer the last ping, remove them.
+ if (!user->lastping)
+ {
+ time_t secs = ServerInstance->Time() - (user->nextping - user->MyClass->GetPingTime());
+ const std::string message = "Ping timeout: " + ConvToStr(secs) + (secs != 1 ? " seconds" : " second");
+ ServerInstance->Users.QuitUser(user, message);
+ return;
+ }
+
+ // Send a ping to the client.
+ ClientProtocol::Messages::Ping ping;
+ user->Send(ServerInstance->GetRFCEvents().ping, ping);
+ user->lastping = 0;
+ user->nextping = ServerInstance->Time() + user->MyClass->GetPingTime();
+ }
+
+ void CheckRegistrationTimeout(LocalUser* user)
+ {
+ if (user->GetClass() && (ServerInstance->Time() > (user->signon + user->GetClass()->GetRegTimeout())))
+ {
+ // Either the user did not send NICK/USER or a module blocked registration in
+ // OnCheckReady until the client timed out.
+ ServerInstance->Users.QuitUser(user, "Registration timeout");
+ }
+ }
+
+ void CheckModulesReady(LocalUser* user)
+ {
+ ModResult res;
+ FIRST_MOD_RESULT(OnCheckReady, res, (user));
+ if (res == MOD_RES_PASSTHRU)
+ {
+ // User has sent NICK/USER and modules are ready.
+ user->FullConnect();
+ return;
+ }
+
+ // If the user has been quit in OnCheckReady then we shouldn't quit
+ // them again for having a registration timeout.
+ if (!user->quitting)
+ CheckRegistrationTimeout(user);
+ }
}
UserManager::UserManager()
this->clientlist[New->nick] = New;
this->AddClone(New);
this->local_users.push_front(New);
+ FOREACH_MOD(OnUserInit, (New));
if (!SocketEngine::AddFd(eh, FD_WANT_FAST_READ | FD_WANT_EDGE_WRITE))
{
ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "BanCache: Positive hit for " + New->GetIPString());
if (!ServerInstance->Config->XLineMessage.empty())
New->WriteNumeric(ERR_YOUREBANNEDCREEP, ServerInstance->Config->XLineMessage);
- this->QuitUser(New, b->Reason);
+
+ if (ServerInstance->Config->HideBans)
+ this->QuitUser(New, b->Type + "-lined", &b->Reason);
+ else
+ this->QuitUser(New, b->Reason);
return;
}
else
FOREACH_MOD(OnSetUserIP, (New));
if (New->quitting)
return;
-
- FOREACH_MOD(OnUserInit, (New));
}
void UserManager::QuitUser(User* user, const std::string& quitreason, const std::string* operreason)
uuidlist.erase(user->uuid);
user->PurgeEmptyChannels();
+ user->UnOper();
}
void UserManager::AddClone(User* user)
}
}
-/* this returns true when all modules are satisfied that the user should be allowed onto the irc server
- * (until this returns true, a user will block in the waiting state, waiting to connect up to the
- * registration timeout maximum seconds)
- */
-bool UserManager::AllModulesReportReady(LocalUser* user)
-{
- ModResult res;
- FIRST_MOD_RESULT(OnCheckReady, res, (user));
- return (res == MOD_RES_PASSTHRU);
-}
-
/**
* This function is called once a second from the mainloop.
* It is intended to do background checking on all the users, e.g. do
switch (curr->registered)
{
case REG_ALL:
- if (ServerInstance->Time() >= curr->nping)
- {
- // This user didn't answer the last ping, remove them
- if (!curr->lastping)
- {
- time_t time = ServerInstance->Time() - (curr->nping - curr->MyClass->GetPingTime());
- const std::string message = "Ping timeout: " + ConvToStr(time) + (time != 1 ? " seconds" : " second");
- this->QuitUser(curr, message);
- continue;
- }
- ClientProtocol::Messages::Ping ping;
- curr->Send(ServerInstance->GetRFCEvents().ping, ping);
- curr->lastping = 0;
- curr->nping = ServerInstance->Time() + curr->MyClass->GetPingTime();
- }
+ CheckPingTimeout(curr);
break;
+
case REG_NICKUSER:
- if (AllModulesReportReady(curr))
- {
- /* User has sent NICK/USER, modules are okay, DNS finished. */
- curr->FullConnect();
- continue;
- }
-
- // If the user has been quit in OnCheckReady then we shouldn't
- // quit them again for having a registration timeout.
- if (curr->quitting)
- continue;
+ CheckModulesReady(curr);
break;
- }
- if (curr->registered != REG_ALL && curr->MyClass && (ServerInstance->Time() > (curr->signon + curr->MyClass->GetRegTimeout())))
- {
- /*
- * registration timeout -- didnt send USER/NICK/HOST
- * in the time specified in their connection class.
- */
- this->QuitUser(curr, "Registration timeout");
- continue;
+ default:
+ CheckRegistrationTimeout(curr);
+ break;
}
}
}