From 054fd8de79ea8b8b9b198e9511df990aea7bd9ff Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 24 Mar 2023 11:22:09 +0000 Subject: Allow modules to provide an error for when a class doesn't match. --- src/users.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/users.cpp') diff --git a/src/users.cpp b/src/users.cpp index 84ad1240f..646949b5a 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -660,6 +660,7 @@ bool LocalUser::FindConnectClass() ServerInstance->Logs.Debug("CONNECTCLASS", "Finding a connect class for {} ({}) ...", uuid, GetRealMask()); + std::optional errnum; for (const auto& klass : ServerInstance->Config->Classes) { ServerInstance->Logs.Debug("CONNECTCLASS", "Checking the {} connect class ...", @@ -674,7 +675,7 @@ bool LocalUser::FindConnectClass() } ModResult modres; - FIRST_MOD_RESULT(OnPreChangeConnectClass, modres, (this, klass)); + FIRST_MOD_RESULT(OnPreChangeConnectClass, modres, (this, klass, errnum)); if (modres != MOD_RES_DENY) { ServerInstance->Logs.Debug("CONNECTCLASS", "The {} connect class is suitable for {} ({}).", @@ -691,6 +692,9 @@ bool LocalUser::FindConnectClass() connectclass->use_count--; connectclass = nullptr; } + + if (errnum) + WriteNumeric(*errnum); ServerInstance->Users.QuitUser(this, "You are not allowed to connect to this server"); return false; } -- cgit v1.3.1-10-gc9f91