mirror of
https://github.com/anope/anope.git
synced 2026-07-04 09:43:13 +02:00
Added m_xmlrpc and m_xmlrpc main, which allows remote programs to execute
remote RPC calls to Anope in realtime and receive responses
This commit is contained in:
@@ -0,0 +1,270 @@
|
||||
#include "module.h"
|
||||
#include "ssl.h"
|
||||
#include "xmlrpc.h"
|
||||
|
||||
class MyXMLRPCClientSocket : public XMLRPCClientSocket
|
||||
{
|
||||
public:
|
||||
MyXMLRPCClientSocket(XMLRPCListenSocket *ls, int fd, const sockaddrs &addr) : XMLRPCClientSocket(ls, fd, addr)
|
||||
{
|
||||
if (ls->username.empty() && ls->password.empty())
|
||||
this->logged_in = true;
|
||||
}
|
||||
|
||||
bool Read(const Anope::string &message)
|
||||
{
|
||||
this->query += message;
|
||||
Log(LOG_DEBUG) << "m_xmlrpc: " << message;
|
||||
|
||||
if (message.find("</methodCall>") != Anope::string::npos)
|
||||
{
|
||||
this->HandleMessage();
|
||||
this->query.clear();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetData(Anope::string &tag, Anope::string &data)
|
||||
{
|
||||
if (this->query.empty())
|
||||
return false;
|
||||
|
||||
Anope::string prev, cur;
|
||||
bool istag;
|
||||
|
||||
do
|
||||
{
|
||||
prev = cur;
|
||||
cur.clear();
|
||||
|
||||
int len = 0;
|
||||
istag = false;
|
||||
|
||||
if (this->query[0] == '<')
|
||||
{
|
||||
len = this->query.find_first_of('>');
|
||||
istag = true;
|
||||
}
|
||||
else if (this->query[0] != '>')
|
||||
{
|
||||
len = this->query.find_first_of('<');
|
||||
}
|
||||
|
||||
if (len)
|
||||
{
|
||||
if (istag)
|
||||
{
|
||||
cur = this->query.substr(1, len - 1);
|
||||
this->query.erase(0, len + 1);
|
||||
while (!this->query.empty() && this->query[0] == ' ')
|
||||
this->query.erase(this->query.begin());
|
||||
}
|
||||
else
|
||||
{
|
||||
cur = this->query.substr(0,len);
|
||||
this->query.erase(0, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (istag && !this->query.empty());
|
||||
|
||||
tag = prev;
|
||||
data = cur;
|
||||
return !istag && !data.empty();
|
||||
}
|
||||
|
||||
void HandleMessage();
|
||||
};
|
||||
|
||||
class MyXMLRPCListenSocket : public XMLRPCListenSocket
|
||||
{
|
||||
public:
|
||||
MyXMLRPCListenSocket(const Anope::string &bindip, int port, bool ipv6, const Anope::string &u, const Anope::string &p, const std::vector<Anope::string> &a) : XMLRPCListenSocket(bindip, port, ipv6, u, p, a) { }
|
||||
|
||||
ClientSocket *OnAccept(int fd, const sockaddrs &addr)
|
||||
{
|
||||
MyXMLRPCClientSocket *socket = new MyXMLRPCClientSocket(this, fd, addr);
|
||||
if (std::find(this->allowed.begin(), this->allowed.end(), addr.addr()) != this->allowed.end())
|
||||
Log() << "m_xmlrpc: Accepted connection " << fd << " from " << addr.addr();
|
||||
else
|
||||
{
|
||||
Log() << "m_xmlrpc: Dropping disallowed connection " << fd << " from " << addr.addr();
|
||||
socket->SetFlag(SF_DEAD);
|
||||
}
|
||||
return socket;
|
||||
}
|
||||
};
|
||||
|
||||
class MyXMLRPCServiceInterface : public XMLRPCServiceInterface
|
||||
{
|
||||
std::deque<XMLRPCEvent *> events;
|
||||
|
||||
public:
|
||||
MyXMLRPCServiceInterface(Module *creator, const Anope::string &sname) : XMLRPCServiceInterface(creator, sname) { }
|
||||
|
||||
void Register(XMLRPCEvent *event)
|
||||
{
|
||||
this->events.push_back(event);
|
||||
}
|
||||
|
||||
void Unregister(XMLRPCEvent *event)
|
||||
{
|
||||
std::deque<XMLRPCEvent *>::iterator it = std::find(this->events.begin(), this->events.end(), event);
|
||||
|
||||
if (it != this->events.end())
|
||||
this->events.erase(it);
|
||||
}
|
||||
|
||||
void Reply(XMLRPCClientSocket *source, XMLRPCRequest *request)
|
||||
{
|
||||
if (!request->id.empty())
|
||||
request->reply("id", request->id);
|
||||
|
||||
Anope::string reply = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<methodCall>\n<methodName>" + request->name + "</methodName>\n<params>\n<param>\n<value>\n<struct>\n";
|
||||
for (std::map<Anope::string, Anope::string>::const_iterator it = request->get_replies().begin(); it != request->get_replies().end(); ++it)
|
||||
{
|
||||
reply += "<member>\n<name>" + it->first + "</name>\n<value>\n<string>" + this->Sanitize(it->second) + "</string>\n</value>\n</member>\n";
|
||||
}
|
||||
reply += "</struct>\n</value>\n</param>\n</params>\n</methodCall>";
|
||||
|
||||
source->Write(reply);
|
||||
}
|
||||
|
||||
Anope::string Sanitize(const Anope::string &string)
|
||||
{
|
||||
static struct special_chars
|
||||
{
|
||||
Anope::string character;
|
||||
Anope::string replace;
|
||||
|
||||
special_chars(const Anope::string &c, const Anope::string &r) : character(c), replace(r) { }
|
||||
}
|
||||
special[] = {
|
||||
special_chars("&", "&"),
|
||||
special_chars("\"", """),
|
||||
special_chars("<", "<"),
|
||||
special_chars(">", "&qt;"),
|
||||
special_chars("'", "'"),
|
||||
special_chars("\n", "
"),
|
||||
special_chars("\002", ""), // bold
|
||||
special_chars("\003", ""), // color
|
||||
special_chars("\35", ""), // italics
|
||||
special_chars("\031", ""), // underline
|
||||
special_chars("\26", ""), // reverses
|
||||
special_chars("", "")
|
||||
};
|
||||
|
||||
Anope::string ret = string;
|
||||
for (int i = 0; special[i].character.empty() == false; ++i)
|
||||
ret = ret.replace_all_cs(special[i].character, special[i].replace);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void RunXMLRPC(XMLRPCClientSocket *source, XMLRPCRequest *request)
|
||||
{
|
||||
for (unsigned i = 0; i < this->events.size(); ++i)
|
||||
{
|
||||
XMLRPCEvent *e = this->events[i];
|
||||
|
||||
e->Run(this, source, request);
|
||||
if (!request->get_replies().empty())
|
||||
this->Reply(source, request);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class ModuleXMLRPC;
|
||||
static ModuleXMLRPC *me;
|
||||
class ModuleXMLRPC : public Module
|
||||
{
|
||||
std::vector<MyXMLRPCListenSocket *> listen_sockets;
|
||||
service_reference<SSLService> sslref;
|
||||
|
||||
public:
|
||||
MyXMLRPCServiceInterface xmlrpcinterface;
|
||||
|
||||
ModuleXMLRPC(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), sslref("ssl"), xmlrpcinterface(this, "xmlrpc")
|
||||
{
|
||||
me = this;
|
||||
|
||||
OnReload(false);
|
||||
|
||||
ModuleManager::RegisterService(&this->xmlrpcinterface);
|
||||
|
||||
Implementation i[] = { I_OnReload };
|
||||
ModuleManager::Attach(i, this, 1);
|
||||
}
|
||||
|
||||
~ModuleXMLRPC()
|
||||
{
|
||||
for (unsigned i = 0; i < this->listen_sockets.size(); ++i)
|
||||
delete this->listen_sockets[i];
|
||||
this->listen_sockets.clear();
|
||||
}
|
||||
|
||||
void OnReload(bool)
|
||||
{
|
||||
ConfigReader config;
|
||||
|
||||
for (unsigned i = 0; i < this->listen_sockets.size(); ++i)
|
||||
delete this->listen_sockets[i];
|
||||
this->listen_sockets.clear();
|
||||
|
||||
for (int i = 0; i < config.Enumerate("m_xmlrpc"); ++i)
|
||||
{
|
||||
Anope::string bindip = config.ReadValue("m_xmlrpc", "bindip", "0.0.0.0", i);
|
||||
int port = config.ReadInteger("m_xmlrpc", "port", 0, i);
|
||||
bool ipv6 = config.ReadFlag("m_xmlrpc", "ipv6", "no", i);
|
||||
bool ssl = config.ReadFlag("m_xmlrpc", "ssl", "no", i);
|
||||
Anope::string allowed = config.ReadValue("m_xmlrpc", "allowed", "127.0.0.1", i);
|
||||
Anope::string username = config.ReadValue("m_xmlrpc", "username", "", i);
|
||||
Anope::string password = config.ReadValue("m_xmlrpc", "password", "", i);
|
||||
std::vector<Anope::string> allowed_vector = BuildStringVector(allowed, ' ');
|
||||
|
||||
if (bindip.empty() || port < 1)
|
||||
continue;
|
||||
|
||||
if (ssl && !sslref)
|
||||
{
|
||||
Log() << "m_xmlrpc: Could not enable SSL, is m_ssl loaded?";
|
||||
ssl = false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
MyXMLRPCListenSocket *xmls = new MyXMLRPCListenSocket(bindip, port, ipv6, username, password, allowed_vector);
|
||||
if (ssl)
|
||||
{
|
||||
sslref->Init(xmls);
|
||||
}
|
||||
this->listen_sockets.push_back(xmls);
|
||||
}
|
||||
catch (const SocketException &ex)
|
||||
{
|
||||
Log() << "m_xmlrpc " << ex.GetReason();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void MyXMLRPCClientSocket::HandleMessage()
|
||||
{
|
||||
Anope::string name, data;
|
||||
XMLRPCRequest request;
|
||||
|
||||
while (this->GetData(name, data))
|
||||
{
|
||||
if (name == "methodName")
|
||||
request.name = data;
|
||||
else if (name == "id")
|
||||
request.id = data;
|
||||
else if (name == "string")
|
||||
request.data.push_back(data);
|
||||
}
|
||||
|
||||
if (request.name == "login" || this->logged_in)
|
||||
me->xmlrpcinterface.RunXMLRPC(this, &request);
|
||||
}
|
||||
|
||||
MODULE_INIT(ModuleXMLRPC)
|
||||
|
||||
@@ -0,0 +1,284 @@
|
||||
#include "module.h"
|
||||
#include "xmlrpc.h"
|
||||
|
||||
class XMLRPCUser : public User
|
||||
{
|
||||
Anope::string out;
|
||||
dynamic_reference<NickAlias> na;
|
||||
|
||||
public:
|
||||
XMLRPCUser(const Anope::string &nnick) : User(nnick, Config->ServiceUser, Config->ServiceHost, ""), na(findnick(nick))
|
||||
{
|
||||
this->realname = "XMLRPC User";
|
||||
this->server = Me;
|
||||
}
|
||||
|
||||
void SendMessage(const Anope::string &source, const Anope::string &msg)
|
||||
{
|
||||
this->out += msg + "\n";
|
||||
}
|
||||
|
||||
NickCore *Account()
|
||||
{
|
||||
return (na ? na->nc : NULL);
|
||||
}
|
||||
|
||||
bool IsIdentified(bool CheckNick = false)
|
||||
{
|
||||
return na;
|
||||
}
|
||||
|
||||
bool IsRecognized(bool CheckSecure = false)
|
||||
{
|
||||
return na;
|
||||
}
|
||||
|
||||
const Anope::string &GetOut()
|
||||
{
|
||||
return this->out;
|
||||
}
|
||||
};
|
||||
|
||||
class MyXMLRPCEvent : public XMLRPCEvent
|
||||
{
|
||||
public:
|
||||
void Run(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request)
|
||||
{
|
||||
if (request->name == "login")
|
||||
this->DoLogin(iface, source, request);
|
||||
else if (request->name == "command")
|
||||
this->DoCommand(iface, source, request);
|
||||
else if (request->name == "checkAuthentication")
|
||||
this->DoCheckAuthentication(iface, source, request);
|
||||
else if (request->name == "stats")
|
||||
this->DoStats(iface, source, request);
|
||||
else if (request->name == "channel")
|
||||
this->DoChannel(iface, source, request);
|
||||
else if (request->name == "user")
|
||||
this->DoUser(iface, source, request);
|
||||
}
|
||||
|
||||
void DoCommand(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request)
|
||||
{
|
||||
Anope::string service = request->data.size() > 0 ? request->data[0] : "";
|
||||
Anope::string user = request->data.size() > 1 ? request->data[1] : "";
|
||||
Anope::string command = request->data.size() > 2 ? request->data[2] : "";
|
||||
|
||||
if (service.empty() || user.empty() || command.empty())
|
||||
request->reply("error", "Invalid parameters");
|
||||
else
|
||||
{
|
||||
BotInfo *bi = findbot(service);
|
||||
if (!bi)
|
||||
request->reply("error", "Invalid service");
|
||||
else
|
||||
{
|
||||
request->reply("result", "Success");
|
||||
|
||||
dynamic_reference<User> u = finduser(user);
|
||||
bool created = false;
|
||||
if (!u)
|
||||
{
|
||||
u = new XMLRPCUser(user);
|
||||
created = true;
|
||||
request->reply("online", "no");
|
||||
}
|
||||
else
|
||||
request->reply("online", "yes");
|
||||
|
||||
mod_run_cmd(bi, *u, command);
|
||||
|
||||
if (created && u)
|
||||
{
|
||||
XMLRPCUser *myu = debug_cast<XMLRPCUser *>(*u);
|
||||
if (!myu->GetOut().empty())
|
||||
request->reply("return", iface->Sanitize(myu->GetOut()));
|
||||
delete *u;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DoLogin(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request)
|
||||
{
|
||||
if (source->logged_in)
|
||||
request->reply("result", "Logged in");
|
||||
else
|
||||
{
|
||||
XMLRPCListenSocket *ls = static_cast<XMLRPCListenSocket *>(source->LS);
|
||||
|
||||
if (ls->username.empty() && ls->password.empty())
|
||||
request->reply("result", "Logged in");
|
||||
else if (request->data.size() > 1 && request->data[0] == ls->username && request->data[1] == ls->password)
|
||||
request->reply("result", "Logged in");
|
||||
else
|
||||
request->reply("error", "Invalid credentials");
|
||||
}
|
||||
}
|
||||
|
||||
void DoCheckAuthentication(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request)
|
||||
{
|
||||
Anope::string username = request->data.size() > 0 ? request->data[0] : "";
|
||||
Anope::string password = request->data.size() > 1 ? request->data[1] : "";
|
||||
|
||||
if (username.empty() || password.empty())
|
||||
request->reply("error", "Invalid parameters");
|
||||
else
|
||||
{
|
||||
NickAlias *na = findnick(username);
|
||||
|
||||
if (!na)
|
||||
request->reply("error", "Invalid account");
|
||||
else if (enc_check_password(password, na->nc->pass) == 1)
|
||||
{
|
||||
request->reply("result", "Success");
|
||||
request->reply("account", na->nc->display);
|
||||
}
|
||||
else
|
||||
request->reply("error", "Invalid password");
|
||||
}
|
||||
}
|
||||
|
||||
void DoStats(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request)
|
||||
{
|
||||
if (SGLine)
|
||||
request->reply("sglinecount", stringify(SGLine->GetCount()));
|
||||
if (SQLine)
|
||||
request->reply("sqlinecount", stringify(SQLine->GetCount()));
|
||||
if (SNLine)
|
||||
request->reply("snlinecount", stringify(SNLine->GetCount()));
|
||||
if (SZLine)
|
||||
request->reply("szlinecount", stringify(SZLine->GetCount()));
|
||||
request->reply("uptime", stringify(Anope::CurTime - start_time));
|
||||
request->reply("uplinkname", Me->GetLinks().front()->GetName());
|
||||
{
|
||||
Anope::string buf;
|
||||
for (unsigned j = 0; !Capab_Info[j].Token.empty(); ++j)
|
||||
if (Capab.HasFlag(Capab_Info[j].Flag))
|
||||
buf += " " + Capab_Info[j].Token;
|
||||
request->reply("uplinkcapab", buf);
|
||||
}
|
||||
request->reply("usercount", stringify(usercnt));
|
||||
request->reply("maxusercount", stringify(maxusercnt));
|
||||
request->reply("channelcount", stringify(ChannelList.size()));
|
||||
}
|
||||
|
||||
void DoChannel(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request)
|
||||
{
|
||||
if (request->data.empty())
|
||||
return;
|
||||
|
||||
Channel *c = findchan(request->data[0]);
|
||||
|
||||
request->reply("name", iface->Sanitize(c ? c->name : request->data[0]));
|
||||
|
||||
if (c)
|
||||
{
|
||||
request->reply("bancount", stringify((c && c->bans ? c->bans->count : 0)));
|
||||
if (c->bans && c->bans->count)
|
||||
{
|
||||
int i = 0;
|
||||
for (Entry *entry = c->bans->entries; entry; entry = entry->next, ++i)
|
||||
request->reply("ban" + stringify(i), iface->Sanitize(entry->mask));
|
||||
}
|
||||
request->reply("exceptcount", stringify((c && c->excepts ? c->excepts->count : 0)));
|
||||
if (c->excepts && c->excepts->count)
|
||||
{
|
||||
int i = 0;
|
||||
for (Entry *entry = c->excepts->entries; entry; entry = entry->next, ++i)
|
||||
request->reply("except" + stringify(i), iface->Sanitize(entry->mask));
|
||||
}
|
||||
request->reply("invitecount", stringify((c && c->invites ? c->invites->count : 0)));
|
||||
if (c->invites && c->invites->count)
|
||||
{
|
||||
int i = 0;
|
||||
for (Entry *entry = c->invites->entries; entry; entry = entry->next, ++i)
|
||||
request->reply("invite" + stringify(i), iface->Sanitize(entry->mask));
|
||||
}
|
||||
|
||||
Anope::string users;
|
||||
for (CUserList::const_iterator it = c->users.begin(); it != c->users.end(); ++it)
|
||||
{
|
||||
UserContainer *uc = *it;
|
||||
users += uc->Status->BuildModePrefixList() + uc->user->nick + " ";
|
||||
}
|
||||
if (!users.empty())
|
||||
{
|
||||
users.erase(users.length() - 1);
|
||||
request->reply("users", iface->Sanitize(users));
|
||||
}
|
||||
|
||||
if (!c->topic.empty())
|
||||
request->reply("topic", iface->Sanitize(c->topic));
|
||||
|
||||
if (!c->topic_setter.empty())
|
||||
request->reply("topicsetter", iface->Sanitize(c->topic_setter));
|
||||
|
||||
request->reply("topictime", stringify(c->topic_time));
|
||||
}
|
||||
}
|
||||
|
||||
void DoUser(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request)
|
||||
{
|
||||
if (request->data.empty())
|
||||
return;
|
||||
|
||||
User *u = finduser(request->data[0]);
|
||||
|
||||
request->reply("nick", iface->Sanitize(u ? u->nick : request->data[0]));
|
||||
|
||||
if (u)
|
||||
{
|
||||
request->reply("ident", iface->Sanitize(u->GetIdent()));
|
||||
request->reply("vident", iface->Sanitize(u->GetVIdent()));
|
||||
request->reply("host", iface->Sanitize(u->host));
|
||||
if (!u->vhost.empty())
|
||||
request->reply("vhost", iface->Sanitize(u->vhost));
|
||||
if (!u->chost.empty())
|
||||
request->reply("chost", iface->Sanitize(u->chost));
|
||||
if (u->ip())
|
||||
request->reply("ip", u->ip.addr());
|
||||
request->reply("timestamp", stringify(u->timestamp));
|
||||
request->reply("signon", stringify(u->my_signon));
|
||||
if (u->Account())
|
||||
request->reply("account", iface->Sanitize(u->Account()->display));
|
||||
|
||||
Anope::string channels;
|
||||
for (UChannelList::const_iterator it = u->chans.begin(); it != u->chans.end(); ++it)
|
||||
{
|
||||
ChannelContainer *cc = *it;
|
||||
channels += cc->Status->BuildModePrefixList() + cc->chan->name + " ";
|
||||
}
|
||||
if (!channels.empty())
|
||||
{
|
||||
channels.erase(channels.length() - 1);
|
||||
request->reply("channels", channels);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class ModuleXMLRPCMain : public Module
|
||||
{
|
||||
service_reference<XMLRPCServiceInterface> xmlrpc;
|
||||
|
||||
MyXMLRPCEvent stats;
|
||||
|
||||
public:
|
||||
ModuleXMLRPCMain(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), xmlrpc("xmlrpc")
|
||||
{
|
||||
if (!xmlrpc)
|
||||
throw ModuleException("Unable to find xmlrpc reference, is m_xmlrpc loaded?");
|
||||
|
||||
xmlrpc->Register(&stats);
|
||||
}
|
||||
|
||||
~ModuleXMLRPCMain()
|
||||
{
|
||||
if (xmlrpc)
|
||||
xmlrpc->Unregister(&stats);
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(ModuleXMLRPCMain)
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
|
||||
class XMLRPCClientSocket;
|
||||
class XMLRPCListenSocket;
|
||||
class XMLRPCServiceInterface;
|
||||
|
||||
class XMLRPCClientSocket : public ClientSocket
|
||||
{
|
||||
protected:
|
||||
Anope::string query;
|
||||
|
||||
public:
|
||||
bool logged_in;
|
||||
|
||||
XMLRPCClientSocket(ListenSocket *ls, int fd, const sockaddrs &addr) : ClientSocket(ls, fd, addr), logged_in(false) { }
|
||||
|
||||
virtual ~XMLRPCClientSocket() { }
|
||||
|
||||
virtual bool Read(const Anope::string &message) = 0;
|
||||
|
||||
virtual bool GetData(Anope::string &tag, Anope::string &data) = 0;
|
||||
|
||||
virtual void HandleMessage() = 0;
|
||||
};
|
||||
|
||||
class XMLRPCListenSocket : public ListenSocket
|
||||
{
|
||||
protected:
|
||||
std::vector<Anope::string> allowed;
|
||||
|
||||
public:
|
||||
Anope::string username;
|
||||
Anope::string password;
|
||||
|
||||
XMLRPCListenSocket(const Anope::string &bindip, int port, bool ipv6, const Anope::string &u, const Anope::string &p, const std::vector<Anope::string> &a) : ListenSocket(bindip, port, ipv6), allowed(a), username(u), password(p) { }
|
||||
|
||||
virtual ~XMLRPCListenSocket() { }
|
||||
|
||||
virtual ClientSocket *OnAccept(int fd, const sockaddrs &addr) = 0;
|
||||
};
|
||||
|
||||
class XMLRPCRequest
|
||||
{
|
||||
std::map<Anope::string, Anope::string> replies;
|
||||
|
||||
public:
|
||||
Anope::string name;
|
||||
Anope::string id;
|
||||
std::deque<Anope::string> data;
|
||||
|
||||
inline void reply(const Anope::string &dname, const Anope::string &ddata) { this->replies.insert(std::make_pair(dname, ddata)); }
|
||||
inline const std::map<Anope::string, Anope::string> &get_replies() { return this->replies; }
|
||||
};
|
||||
|
||||
class XMLRPCEvent
|
||||
{
|
||||
public:
|
||||
virtual void Run(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request) = 0;
|
||||
};
|
||||
|
||||
class XMLRPCServiceInterface : public Service
|
||||
{
|
||||
public:
|
||||
XMLRPCServiceInterface(Module *creator, const Anope::string &sname) : Service(creator, sname) { }
|
||||
|
||||
virtual void Register(XMLRPCEvent *event) = 0;
|
||||
|
||||
virtual void Unregister(XMLRPCEvent *event) = 0;
|
||||
|
||||
virtual void Reply(XMLRPCClientSocket *source, XMLRPCRequest *request) = 0;
|
||||
|
||||
virtual Anope::string Sanitize(const Anope::string &string) = 0;
|
||||
|
||||
virtual void RunXMLRPC(XMLRPCClientSocket *source, XMLRPCRequest *request) = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user