diff options
-rw-r--r-- | data/modules.example.conf | 8 | ||||
-rw-r--r-- | docs/RPC/XMLRPC (renamed from docs/XMLRPC/XMLRPC) | 2 | ||||
-rw-r--r-- | docs/RPC/xmlrpc.php (renamed from docs/XMLRPC/xmlrpc.php) | 0 | ||||
-rw-r--r-- | include/modules/rpc.h (renamed from include/modules/xmlrpc.h) | 22 | ||||
-rw-r--r-- | modules/rpc/rpc_main.cpp (renamed from modules/xmlrpc_main.cpp) | 58 | ||||
-rw-r--r-- | modules/rpc/xmlrpc.cpp (renamed from modules/xmlrpc.cpp) | 20 |
6 files changed, 55 insertions, 55 deletions
diff --git a/data/modules.example.conf b/data/modules.example.conf index 917f72c61..604f05c43 100644 --- a/data/modules.example.conf +++ b/data/modules.example.conf @@ -789,7 +789,7 @@ module { name = "sasl" } * xmlrpc * * Allows remote applications (websites) to execute queries in real time to retrieve data from Anope. - * By itself this module does nothing, but allows other modules (xmlrpc_main) to receive and send XMLRPC queries. + * By itself this module does nothing, but allows other modules (rpc_main) to receive and send XMLRPC queries. */ #module { @@ -800,9 +800,9 @@ module { name = "sasl" } } /* - * xmlrpc_main + * rpc_main * - * Adds the main XMLRPC core functions. + * Adds the main RPC core functions. * Requires xmlrpc. */ -#module { name = "xmlrpc_main" } +#module { name = "rpc_main" } diff --git a/docs/XMLRPC/XMLRPC b/docs/RPC/XMLRPC index 72f81e4b8..ac3f1059b 100644 --- a/docs/XMLRPC/XMLRPC +++ b/docs/RPC/XMLRPC @@ -1,7 +1,7 @@ XMLRPC using PHP's xmlrpc_encode_request and xmlrpc_decode functions is supported. This allows external applications, such as websites, to execute remote procedure calls to Anope in real time. -Currently there are 5 supported XMLRPC calls, provided by xmlrpc_main: +Currently there are 5 supported XMLRPC calls, provided by rpc_main: checkAuthentication - Takes two parameters, an account name and a password. Checks if the account name is valid and the password is correct for the account name, useful for making login pages on websites. diff --git a/docs/XMLRPC/xmlrpc.php b/docs/RPC/xmlrpc.php index 90f07a944..90f07a944 100644 --- a/docs/XMLRPC/xmlrpc.php +++ b/docs/RPC/xmlrpc.php diff --git a/include/modules/xmlrpc.h b/include/modules/rpc.h index 833792888..b3c8afdb4 100644 --- a/include/modules/xmlrpc.h +++ b/include/modules/rpc.h @@ -10,7 +10,7 @@ #include "httpd.h" -class XMLRPCRequest final +class RPCRequest final { std::map<Anope::string, Anope::string> replies; @@ -20,31 +20,31 @@ public: std::deque<Anope::string> data; HTTPReply &r; - XMLRPCRequest(HTTPReply &_r) : r(_r) { } + RPCRequest(HTTPReply &_r) : r(_r) { } inline void reply(const Anope::string &dname, const Anope::string &ddata) { this->replies.emplace(dname, ddata); } inline const std::map<Anope::string, Anope::string> &get_replies() { return this->replies; } }; -class XMLRPCServiceInterface; +class RPCServiceInterface; -class XMLRPCEvent +class RPCEvent { public: - virtual ~XMLRPCEvent() = default; - virtual bool Run(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) = 0; + virtual ~RPCEvent() = default; + virtual bool Run(RPCServiceInterface *iface, HTTPClient *client, RPCRequest &request) = 0; }; -class XMLRPCServiceInterface +class RPCServiceInterface : public Service { public: - XMLRPCServiceInterface(Module *creator, const Anope::string &sname) : Service(creator, "XMLRPCServiceInterface", sname) { } + RPCServiceInterface(Module *creator, const Anope::string &sname) : Service(creator, "RPCServiceInterface", sname) { } - virtual void Register(XMLRPCEvent *event) = 0; + virtual void Register(RPCEvent *event) = 0; - virtual void Unregister(XMLRPCEvent *event) = 0; + virtual void Unregister(RPCEvent *event) = 0; virtual Anope::string Sanitize(const Anope::string &string) = 0; - virtual void Reply(XMLRPCRequest &request) = 0; + virtual void Reply(RPCRequest &request) = 0; }; diff --git a/modules/xmlrpc_main.cpp b/modules/rpc/rpc_main.cpp index 3cfec74e8..4a87d9e05 100644 --- a/modules/xmlrpc_main.cpp +++ b/modules/rpc/rpc_main.cpp @@ -7,21 +7,21 @@ */ #include "module.h" -#include "modules/xmlrpc.h" +#include "modules/rpc.h" static Module *me; -class XMLRPCIdentifyRequest final +class RPCIdentifyRequest final : public IdentifyRequest { - XMLRPCRequest request; + RPCRequest request; HTTPReply repl; /* Request holds a reference to the HTTPReply, because we might exist long enough to invalidate it we'll copy it here then reset the reference before we use it */ Reference<HTTPClient> client; - Reference<XMLRPCServiceInterface> xinterface; + Reference<RPCServiceInterface> xinterface; public: - XMLRPCIdentifyRequest(Module *m, XMLRPCRequest &req, HTTPClient *c, XMLRPCServiceInterface *iface, const Anope::string &acc, const Anope::string &pass) : IdentifyRequest(m, acc, pass), request(req), repl(request.r), client(c), xinterface(iface) { } + RPCIdentifyRequest(Module *m, RPCRequest &req, HTTPClient *c, RPCServiceInterface *iface, const Anope::string &acc, const Anope::string &pass) : IdentifyRequest(m, acc, pass), request(req), repl(request.r), client(c), xinterface(iface) { } void OnSuccess() override { @@ -51,11 +51,11 @@ public: } }; -class MyXMLRPCEvent final - : public XMLRPCEvent +class MyRPCEvent final + : public RPCEvent { public: - bool Run(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) override + bool Run(RPCServiceInterface *iface, HTTPClient *client, RPCRequest &request) override { if (request.name == "command") this->DoCommand(iface, client, request); @@ -76,7 +76,7 @@ public: } private: - void DoCommand(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) + void DoCommand(RPCServiceInterface *iface, HTTPClient *client, RPCRequest &request) { Anope::string service = request.data.size() > 0 ? request.data[0] : ""; Anope::string user = request.data.size() > 1 ? request.data[1] : ""; @@ -97,12 +97,12 @@ private: Anope::string out; - struct XMLRPCommandReply final + struct RPCommandReply final : CommandReply { Anope::string &str; - XMLRPCommandReply(Anope::string &s) : str(s) { } + RPCommandReply(Anope::string &s) : str(s) { } void SendMessage(BotInfo *source, const Anope::string &msg) override { @@ -121,7 +121,7 @@ private: } } - static bool DoCheckAuthentication(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) + static bool DoCheckAuthentication(RPCServiceInterface *iface, HTTPClient *client, RPCRequest &request) { Anope::string username = request.data.size() > 0 ? request.data[0] : ""; Anope::string password = request.data.size() > 1 ? request.data[1] : ""; @@ -130,7 +130,7 @@ private: request.reply("error", "Invalid parameters"); else { - auto *req = new XMLRPCIdentifyRequest(me, request, client, iface, username, password); + auto *req = new RPCIdentifyRequest(me, request, client, iface, username, password); FOREACH_MOD(OnCheckAuthentication, (NULL, req)); req->Dispatch(); return false; @@ -139,7 +139,7 @@ private: return true; } - static void DoStats(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) + static void DoStats(RPCServiceInterface *iface, HTTPClient *client, RPCRequest &request) { request.reply("uptime", Anope::ToString(Anope::CurTime - Anope::StartTime)); request.reply("uplinkname", Me->GetLinks().front()->GetName()); @@ -156,7 +156,7 @@ private: request.reply("channelcount", Anope::ToString(ChannelList.size())); } - static void DoChannel(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) + static void DoChannel(RPCServiceInterface *iface, HTTPClient *client, RPCRequest &request) { if (request.data.empty()) return; @@ -205,7 +205,7 @@ private: } } - static void DoUser(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) + static void DoUser(RPCServiceInterface *iface, HTTPClient *client, RPCRequest &request) { if (request.data.empty()) return; @@ -247,7 +247,7 @@ private: } } - static void DoOperType(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) + static void DoOperType(RPCServiceInterface *iface, HTTPClient *client, RPCRequest &request) { for (auto *ot : Config->MyOperTypes) { @@ -260,7 +260,7 @@ private: } } - static void DoNotice(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) + static void DoNotice(RPCServiceInterface *iface, HTTPClient *client, RPCRequest &request) { Anope::string from = request.data.size() > 0 ? request.data[0] : ""; Anope::string to = request.data.size() > 1 ? request.data[1] : ""; @@ -278,29 +278,29 @@ private: } }; -class ModuleXMLRPCMain final +class ModuleRPCMain final : public Module { - ServiceReference<XMLRPCServiceInterface> xmlrpc; + ServiceReference<RPCServiceInterface> rpc; - MyXMLRPCEvent stats; + MyRPCEvent stats; public: - ModuleXMLRPCMain(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), xmlrpc("XMLRPCServiceInterface", "xmlrpc") + ModuleRPCMain(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), rpc("RPCServiceInterface", "rpc") { me = this; - if (!xmlrpc) - throw ModuleException("Unable to find xmlrpc reference, is xmlrpc loaded?"); + if (!rpc) + throw ModuleException("Unable to find RPC interface, is xmlrpc loaded?"); - xmlrpc->Register(&stats); + rpc->Register(&stats); } - ~ModuleXMLRPCMain() override + ~ModuleRPCMain() override { - if (xmlrpc) - xmlrpc->Unregister(&stats); + if (rpc) + rpc->Unregister(&stats); } }; -MODULE_INIT(ModuleXMLRPCMain) +MODULE_INIT(ModuleRPCMain) diff --git a/modules/xmlrpc.cpp b/modules/rpc/xmlrpc.cpp index 480c248bf..f1db6efba 100644 --- a/modules/xmlrpc.cpp +++ b/modules/rpc/xmlrpc.cpp @@ -7,7 +7,7 @@ */ #include "module.h" -#include "modules/xmlrpc.h" +#include "modules/rpc.h" #include "modules/httpd.h" static struct special_chars final @@ -33,22 +33,22 @@ special[] = { }; class MyXMLRPCServiceInterface final - : public XMLRPCServiceInterface + : public RPCServiceInterface , public HTTPPage { - std::deque<XMLRPCEvent *> events; + std::deque<RPCEvent *> events; public: - MyXMLRPCServiceInterface(Module *creator, const Anope::string &sname) : XMLRPCServiceInterface(creator, sname), HTTPPage("/xmlrpc", "text/xml") { } + MyXMLRPCServiceInterface(Module *creator, const Anope::string &sname) : RPCServiceInterface(creator, sname), HTTPPage("/xmlrpc", "text/xml") { } - void Register(XMLRPCEvent *event) override + void Register(RPCEvent *event) override { this->events.push_back(event); } - void Unregister(XMLRPCEvent *event) override + void Unregister(RPCEvent *event) override { - std::deque<XMLRPCEvent *>::iterator it = std::find(this->events.begin(), this->events.end(), event); + std::deque<RPCEvent *>::iterator it = std::find(this->events.begin(), this->events.end(), event); if (it != this->events.end()) this->events.erase(it); @@ -150,7 +150,7 @@ public: bool OnRequest(HTTPProvider *provider, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) override { Anope::string content = message.content, tname, data; - XMLRPCRequest request(reply); + RPCRequest request(reply); while (GetData(content, tname, data)) { @@ -182,7 +182,7 @@ public: return true; } - void Reply(XMLRPCRequest &request) override + void Reply(RPCRequest &request) override { if (!request.id.empty()) request.reply("id", request.id); @@ -204,7 +204,7 @@ public: MyXMLRPCServiceInterface xmlrpcinterface; ModuleXMLRPC(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), - xmlrpcinterface(this, "xmlrpc") + xmlrpcinterface(this, "rpc") { } |