summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/modules.cpp1
-rw-r--r--src/usermanager.cpp10
-rw-r--r--src/users.cpp7
3 files changed, 16 insertions, 2 deletions
diff --git a/src/modules.cpp b/src/modules.cpp
index 3e268dae6..6f7ca2694 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -140,6 +140,7 @@ void Module::OnSetUserIP(LocalUser*) { DetachEvent(I_OnSetUserIP); }
void Module::OnServiceAdd(ServiceProvider&) { DetachEvent(I_OnServiceAdd); }
void Module::OnServiceDel(ServiceProvider&) { DetachEvent(I_OnServiceDel); }
ModResult Module::OnUserWrite(LocalUser*, ClientProtocol::Message&) { DetachEvent(I_OnUserWrite); return MOD_RES_PASSTHRU; }
+ModResult Module::OnConnectionFail(LocalUser*, BufferedSocketError) { DetachEvent(I_OnConnectionFail); return MOD_RES_PASSTHRU; }
ServiceProvider::ServiceProvider(Module* Creator, const std::string& Name, ServiceType Type)
: creator(Creator), name(Name), service(Type)
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index 6acd25ac5..4f65994aa 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -58,6 +58,16 @@ namespace
// This user didn't answer the last ping, remove them.
if (!user->lastping)
{
+ ModResult res;
+ FIRST_MOD_RESULT(OnConnectionFail, res, (user, I_ERR_TIMEOUT));
+ if (res == MOD_RES_ALLOW)
+ {
+ // A module is preventing this user from being timed out.
+ user->lastping = 1;
+ user->nextping = ServerInstance->Time() + user->MyClass->GetPingTime();
+ return;
+ }
+
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);
diff --git a/src/users.cpp b/src/users.cpp
index a3807bd75..c0dc69ff4 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -308,9 +308,12 @@ bool UserIOHandler::OnSetEndPoint(const irc::sockets::sockaddrs& server, const i
return !user->quitting;
}
-void UserIOHandler::OnError(BufferedSocketError)
+void UserIOHandler::OnError(BufferedSocketError error)
{
- ServerInstance->Users->QuitUser(user, getError());
+ ModResult res;
+ FIRST_MOD_RESULT(OnConnectionFail, res, (user, error));
+ if (res != MOD_RES_ALLOW)
+ ServerInstance->Users->QuitUser(user, getError());
}
CullResult User::cull()