diff options
author | Adam <Adam@anope.org> | 2010-12-10 15:34:52 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-12-12 19:37:04 -0500 |
commit | 2a4d0e3e898f1ee2395b5e83198d68a5e646a640 (patch) | |
tree | 3c2b4cc157c04e97e5db2b136bac4b81e55d3978 /modules | |
parent | 9f7a2e4da2c9917ae7a0fb2729609ef03093a312 (diff) |
Allow getting users opertype from XMLRPC requests
Diffstat (limited to 'modules')
-rw-r--r-- | modules/extra/m_xmlrpc.cpp | 2 | ||||
-rw-r--r-- | modules/extra/m_xmlrpc_main.cpp | 26 |
2 files changed, 28 insertions, 0 deletions
diff --git a/modules/extra/m_xmlrpc.cpp b/modules/extra/m_xmlrpc.cpp index 4b15499b8..b345ce183 100644 --- a/modules/extra/m_xmlrpc.cpp +++ b/modules/extra/m_xmlrpc.cpp @@ -18,6 +18,7 @@ class MyXMLRPCClientSocket : public XMLRPCClientSocket if (message.find("</methodCall>") != Anope::string::npos) { + Log(LOG_DEBUG) << "m_xmlrpc: Processing message"; this->HandleMessage(); this->query.clear(); } @@ -254,6 +255,7 @@ void MyXMLRPCClientSocket::HandleMessage() while (this->GetData(name, data)) { + Log(LOG_DEBUG) << "m_xmlrpc: Tag name: " << name << ", data: " << data; if (name == "methodName") request.name = data; else if (name == "name" && data == "id") diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp index 59088792f..8d4cdf56e 100644 --- a/modules/extra/m_xmlrpc_main.cpp +++ b/modules/extra/m_xmlrpc_main.cpp @@ -1,6 +1,7 @@ #include "module.h" #include "xmlrpc.h" +// XXX We no longer need this, we need to modify CommandSource to allow commands to go back here class XMLRPCUser : public User { Anope::string out; @@ -56,6 +57,8 @@ class MyXMLRPCEvent : public XMLRPCEvent this->DoChannel(iface, source, request); else if (request->name == "user") this->DoUser(iface, source, request); + else if (request->name == "opers") + this->DoOperType(iface, source, request); } void DoCommand(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request) @@ -108,9 +111,15 @@ class MyXMLRPCEvent : public XMLRPCEvent XMLRPCListenSocket *ls = static_cast<XMLRPCListenSocket *>(source->LS); if (ls->username.empty() && ls->password.empty()) + { request->reply("result", "Logged in"); + source->logged_in = true; + } else if (request->data.size() > 1 && request->data[0] == ls->username && request->data[1] == ls->password) + { request->reply("result", "Logged in"); + source->logged_in = true; + } else request->reply("error", "Invalid credentials"); } @@ -237,7 +246,11 @@ class MyXMLRPCEvent : public XMLRPCEvent request->reply("timestamp", stringify(u->timestamp)); request->reply("signon", stringify(u->my_signon)); if (u->Account()) + { request->reply("account", iface->Sanitize(u->Account()->display)); + if (u->Account()->ot) + request->reply("opertype", iface->Sanitize(u->Account()->ot->GetName())); + } Anope::string channels; for (UChannelList::const_iterator it = u->chans.begin(); it != u->chans.end(); ++it) @@ -252,6 +265,19 @@ class MyXMLRPCEvent : public XMLRPCEvent } } } + + void DoOperType(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request) + { + for (std::list<OperType *>::const_iterator it = Config->MyOperTypes.begin(), it_end = Config->MyOperTypes.end(); it != it_end; ++it) + { + Anope::string perms; + for (std::list<Anope::string>::const_iterator it2 = (*it)->GetPrivs().begin(), it2_end = (*it)->GetPrivs().end(); it2 != it2_end; ++it2) + perms += " " + *it2; + for (std::list<Anope::string>::const_iterator it2 = (*it)->GetCommands().begin(), it2_end = (*it)->GetCommands().end(); it2 != it2_end; ++it2) + perms += " " + *it2; + request->reply((*it)->GetName(), perms); + } + } }; class ModuleXMLRPCMain : public Module |