X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_jumpserver.cpp;h=682e353d2b92e2f70cb08c9bfc3a0abd28aa2829;hb=99af213a58946185621b3e4de01970a7c21cce93;hp=599144448833c1aea22837fbfd4543b915151672;hpb=6fe1f4e1136f2ab95a88e68af1894bf6002d03f4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_jumpserver.cpp b/src/modules/m_jumpserver.cpp index 599144448..682e353d2 100644 --- a/src/modules/m_jumpserver.cpp +++ b/src/modules/m_jumpserver.cpp @@ -22,6 +22,12 @@ #include "inspircd.h" #include "modules/ssl.h" +enum +{ + // From ircd-ratbox. + RPL_REDIR = 10 +}; + /** Handle /JUMPSERVER */ class CommandJumpserver : public Command @@ -42,7 +48,7 @@ class CommandJumpserver : public Command redirect_new_users = false; } - CmdResult Handle (const std::vector ¶meters, User *user) + CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE { int n_done = 0; reason = (parameters.size() < 4) ? "Please use this server/port instead" : parameters[3]; @@ -52,7 +58,7 @@ class CommandJumpserver : public Command std::string n_done_s; /* No parameters: jumpserver disabled */ - if (!parameters.size()) + if (parameters.empty()) { if (port) user->WriteNotice("*** Disabled jumpserver (previously set to '" + redirect_to + ":" + ConvToStr(port) + "')"); @@ -109,12 +115,14 @@ class CommandJumpserver : public Command { /* Redirect everyone but the oper sending the command */ const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers(); - for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i) + for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ) { + // Quitting the user removes it from the list LocalUser* t = *i; + ++i; if (!t->IsOper()) { - t->WriteNumeric(RPL_REDIR, "%s %d :Please use this Server/Port instead", parameters[0].c_str(), GetPort(t)); + t->WriteNumeric(RPL_REDIR, parameters[0], GetPort(t), "Please use this Server/Port instead"); ServerInstance->Users->QuitUser(t, reason); n_done++; } @@ -138,7 +146,7 @@ class CommandJumpserver : public Command int GetPort(LocalUser* user) { - int p = (SSLClientCert::GetCertificate(&user->eh) ? sslport : port); + int p = (SSLIOHook::IsSSL(&user->eh) ? sslport : port); if (p == 0) p = user->GetServerPort(); return p; @@ -153,15 +161,20 @@ class ModuleJumpServer : public Module { } + void OnModuleRehash(User* user, const std::string& param) CXX11_OVERRIDE + { + if (irc::equals(param, "jumpserver") && js.redirect_new_users) + js.redirect_new_users = false; + } + ModResult OnUserRegister(LocalUser* user) CXX11_OVERRIDE { if (js.redirect_new_users) { int port = js.GetPort(user); - user->WriteNumeric(RPL_REDIR, "%s %d :Please use this Server/Port instead", - js.redirect_to.c_str(), port); + user->WriteNumeric(RPL_REDIR, js.redirect_to, port, "Please use this Server/Port instead"); ServerInstance->Users->QuitUser(user, js.reason); - return MOD_RES_PASSTHRU; + return MOD_RES_DENY; } return MOD_RES_PASSTHRU; }