Anope IRC Services  Version 2.0
os_jupe.cpp
Go to the documentation of this file.
1 /* OperServ core functions
2  *
3  * (C) 2003-2014 Anope Team
4  * Contact us at team@anope.org
5  *
6  * Please read COPYING and README for further details.
7  *
8  * Based on the original code of Epona by Lara.
9  * Based on the original code of Services by Andy Church.
10  */
11 
12 #include "module.h"
13 
14 class CommandOSJupe : public Command
15 {
16  public:
17  CommandOSJupe(Module *creator) : Command(creator, "operserv/jupe", 1, 2)
18  {
19  this->SetDesc(_("\"Jupiter\" a server"));
20  this->SetSyntax(_("\037server\037 [\037reason\037]"));
21  }
22 
23  void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
24  {
25  const Anope::string &jserver = params[0];
26  const Anope::string &reason = params.size() > 1 ? params[1] : "";
27  Server *server = Server::Find(jserver, true);
28 
29  if (!IRCD->IsHostValid(jserver) || jserver.find('.') == Anope::string::npos)
30  source.Reply(_("Please use a valid server name when juping."));
31  else if (server == Me || server == Servers::GetUplink())
32  source.Reply(_("You can not jupe your Services' pseudoserver or your uplink server."));
33  else if (server && server->IsJuped())
34  source.Reply(_("You can not jupe an already juped server."));
35  else
36  {
37  Anope::string rbuf = "Juped by " + source.GetNick() + (!reason.empty() ? ": " + reason : "");
38  /* Generate the new sid before quitting the old server, so they can't collide */
40  if (server)
41  {
42  IRCD->SendSquit(server, rbuf);
43  server->Delete(rbuf);
44  }
45  Server *juped_server = new Server(Me, jserver, 1, rbuf, sid, true);
46  IRCD->SendServer(juped_server);
47 
48  Log(LOG_ADMIN, source, this) << "on " << jserver << " (" << rbuf << ")";
49  }
50  }
51 
52  bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
53  {
54  this->SendSyntax(source);
55  source.Reply(" ");
56  source.Reply(_("Tells Services to jupiter a server -- that is, to create\n"
57  "a fake \"server\" connected to Services which prevents\n"
58  "the real server of that name from connecting. The jupe\n"
59  "may be removed using a standard \002SQUIT\002. If a reason is\n"
60  "given, it is placed in the server information field;\n"
61  "otherwise, the server information field will contain the\n"
62  "text \"Juped by <nick>\", showing the nickname of the\n"
63  "person who jupitered the server."));
64  return true;
65  }
66 };
67 
68 class OSJupe : public Module
69 {
71 
72  public:
73  OSJupe(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
74  commandosjupe(this)
75  {
76 
77  }
78 };
79 
Definition: servers.h:42
CommandOSJupe commandosjupe
Definition: os_jupe.cpp:70
void Execute(CommandSource &source, const std::vector< Anope::string > &params) anope_override
Definition: os_jupe.cpp:23
OSJupe(const Anope::string &modname, const Anope::string &creator)
Definition: os_jupe.cpp:73
bool IsJuped() const
Definition: servers.cpp:319
void SetDesc(const Anope::string &d)
Definition: command.cpp:130
CoreExport Server * GetUplink()
Definition: servers.cpp:355
virtual bool IsHostValid(const Anope::string &)
Definition: protocol.cpp:401
virtual Anope::string SID_Retrieve()
Definition: protocol.cpp:76
static const size_type npos
Definition: anope.h:44
CommandOSJupe(Module *creator)
Definition: os_jupe.cpp:17
virtual void SendServer(const Server *)=0
#define anope_override
Definition: services.h:56
bool empty() const
Definition: anope.h:126
static Server * Find(const Anope::string &name, bool name_only=false)
Definition: servers.cpp:337
virtual void SendSquit(Server *, const Anope::string &message)
Definition: protocol.cpp:314
CoreExport IRCDProto * IRCD
Definition: protocol.cpp:23
#define MODULE_INIT(x)
Definition: modules.h:45
void SetSyntax(const Anope::string &s)
Definition: command.cpp:140
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
Definition: os_jupe.cpp:52
CoreExport Server * Me
Definition: servers.cpp:24
void SendSyntax(CommandSource &)
Definition: command.cpp:145
Definition: logger.h:53
size_type find(const string &_str, size_type pos=0) const
Definition: anope.h:192
#define _(x)
Definition: services.h:50
void Delete(const Anope::string &reason)
Definition: servers.cpp:167