bool IRCdMessage::OnSQuit(const Anope::string &source, const std::vector<Anope::string> ¶ms) { const Anope::string &server = params[0]; Server *s = Server::Find(server); if (!s) { Log() << "SQUIT for nonexistent server " << server; return true; } FOREACH_MOD(I_OnServerQuit, OnServerQuit(s)); Anope::string buf = s->GetName() + " " + s->GetUplink()->GetName(); if (s->GetUplink() == Me && Capab.count("UNCONNECT") > 0) { Log(LOG_DEBUG) << "Sending UNCONNECT SQUIT for " << s->GetName(); /* need to fix */ ircdproto->SendSquit(s, buf); } s->Delete(buf); return true; }
void SQuit::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Server *s = Server::Find(params[0]); if (!s) { Log(LOG_DEBUG) << "SQUIT for nonexistent server " << params[0]; return; } if (s == Me) { if (Me->GetLinks().empty()) return; s = Me->GetLinks().front(); } s->Delete(s->GetName() + " " + s->GetUplink()->GetName()); }
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &jserver = params[0]; const Anope::string &reason = params.size() > 1 ? params[1] : ""; Server *server = Server::Find(jserver, true); if (!IRCD->IsHostValid(jserver) || jserver.find('.') == Anope::string::npos) { source.Reply(_("\002{0}\002 is not a valid server name."), jserver); return; } if (server == Me || server == Servers::GetUplink() || server->IsULined()) { source.Reply(_("You can not jupe Servoces or its uplink server.")); return; } if (server && server->IsJuped()) { source.Reply(_("You can not jupe an already juped server.")); return; } Anope::string rbuf = "Juped by " + source.GetNick() + (!reason.empty() ? ": " + reason : ""); /* Generate the new sid before quitting the old server, so they can't collide */ Anope::string sid = IRCD->SID_Retrieve(); if (server) { IRCD->Send<messages::SQuit>(server, rbuf); server->Delete(rbuf); } Server *juped_server = new Server(Me, jserver, 1, rbuf, sid, true); IRCD->Send<messages::MessageServer>(juped_server); Log(LOG_ADMIN, source, this) << "on " << jserver << " (" << rbuf << ")"; }