mirror of
https://github.com/anope/anope.git
synced 2026-07-02 14:53:13 +02:00
Add an XML-RPC method to rpc_system for debugging RPC responses.
This commit is contained in:
@@ -15,6 +15,66 @@
|
||||
// * system.methodHelp
|
||||
// * system.methodSignature
|
||||
|
||||
class AnopeDebugTypesRPCEvent final
|
||||
: public RPC::Event
|
||||
{
|
||||
public:
|
||||
AnopeDebugTypesRPCEvent()
|
||||
: RPC::Event("anope.debugTypes")
|
||||
{
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
{
|
||||
// For both the map type and array type we test that we can handle:
|
||||
//
|
||||
// * Arrays
|
||||
// * Maps
|
||||
// * Strings
|
||||
// * Null
|
||||
// * Boolean true
|
||||
// * Boolean false
|
||||
// * Doubles
|
||||
// * Signed integer that can fit into a 32-bit type.
|
||||
// * Signed integer that needs a 64-bit type (not supported by some
|
||||
// XML-RPC clients).
|
||||
// * Unsigned integer that can fit into a 32-bit signed type.
|
||||
// * Unsigned integer that needs a 64-bit signed type (not supported by
|
||||
// some XML-RPC clients).
|
||||
// * Unsigned integer that needs a 64-bit unsigned type (converted to a
|
||||
// string when using the xmlrpc module).
|
||||
|
||||
auto &root = request.Root();
|
||||
|
||||
auto &array = root.ReplyArray("array");
|
||||
array.ReplyArray();
|
||||
array.ReplyMap();
|
||||
array.Reply("string");
|
||||
array.Reply(nullptr);
|
||||
array.Reply(true);
|
||||
array.Reply(false);
|
||||
array.Reply(42.42);
|
||||
array.Reply(int64_t(42));
|
||||
array.Reply(int64_t(INT32_MAX) + 42);
|
||||
array.Reply(uint64_t(42));
|
||||
array.Reply(uint64_t(INT32_MAX) + 42);
|
||||
array.Reply(uint64_t(INT64_MAX) + 42);
|
||||
|
||||
root.ReplyMap("map");
|
||||
root.Reply("string", "string");
|
||||
root.Reply("null", nullptr);
|
||||
root.Reply("true", true);
|
||||
root.Reply("false", false);
|
||||
root.Reply("double", 42.42);
|
||||
root.Reply("int-small", int64_t(42));
|
||||
root.Reply("int-large", int64_t(INT32_MAX) + 42);
|
||||
root.Reply("uint-small", uint64_t(42));
|
||||
root.Reply("uint-medium", uint64_t(INT32_MAX) + 42);
|
||||
root.Reply("uint-large", uint64_t(INT64_MAX) + 42);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class SystemListMethodsRPCEvent final
|
||||
: public RPC::Event
|
||||
@@ -39,6 +99,7 @@ class ModuleRPCSystem final
|
||||
{
|
||||
private:
|
||||
ServiceReference<RPC::ServiceInterface> rpc;
|
||||
AnopeDebugTypesRPCEvent anopedebugtypesrpcevent;
|
||||
SystemListMethodsRPCEvent systemlistmethodsrpcevent;
|
||||
|
||||
public:
|
||||
@@ -49,6 +110,9 @@ public:
|
||||
if (!rpc)
|
||||
throw ModuleException("Unable to find RPC interface, is jsonrpc/xmlrpc loaded?");
|
||||
|
||||
#if DEBUG_BUILD
|
||||
rpc->Register(&anopedebugtypesrpcevent);
|
||||
#endif
|
||||
rpc->Register(&systemlistmethodsrpcevent);
|
||||
}
|
||||
|
||||
@@ -57,6 +121,9 @@ public:
|
||||
if (!rpc)
|
||||
return;
|
||||
|
||||
#if DEBUG_BUILD
|
||||
rpc->Unregister(&anopedebugtypesrpcevent);
|
||||
#endif
|
||||
rpc->Unregister(&systemlistmethodsrpcevent);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user