X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_httpd_stats.cpp;h=6db292eb37c7fe8ae3fd56f90eaf5781dd1a48e6;hb=8ec9a73a91ad1c7009fd3055fbad7c980b5e1732;hp=35a4b0fb2115ee4d50bd4648e909b06f0038b3a1;hpb=a7aa76f17ac22897e08558f0f78d891d3d4f7de6;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index 35a4b0fb2..6db292eb3 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -25,14 +25,15 @@ #include "modules/httpd.h" #include "xline.h" -class ModuleHttpStats : public Module +class ModuleHttpStats : public Module, public HTTPRequestEventListener { static const insp::flat_map& entities; HTTPdAPI API; public: ModuleHttpStats() - : API(this) + : HTTPRequestEventListener(this) + , API(this) { } @@ -87,33 +88,33 @@ class ModuleHttpStats : public Module data << ""; } - void OnEvent(Event& event) CXX11_OVERRIDE + ModResult HandleRequest(HTTPRequest* http) { std::stringstream data(""); - if (event.id == "httpd_url") { ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Handling httpd event"); - HTTPRequest* http = (HTTPRequest*)&event; if ((http->GetURI() == "/stats") || (http->GetURI() == "/stats/")) { - data << "" << ServerInstance->Config->ServerName << "" - << Sanitize(ServerInstance->Config->ServerDesc) << "" + data << "" << ServerInstance->Config->ServerName << "" + << Sanitize(ServerInstance->Config->ServerDesc) << "" << Sanitize(ServerInstance->GetVersionString()) << ""; data << ""; data << "" << ServerInstance->Users->GetUsers().size() << ""; data << "" << ServerInstance->GetChans().size() << ""; data << "" << ServerInstance->Users->all_opers.size() << ""; - data << "" << (SocketEngine::GetUsedFds()) << "" << SocketEngine::GetMaxFds() << "" INSPIRCD_SOCKETENGINE_NAME ""; + data << "" << (SocketEngine::GetUsedFds()) << "" << SocketEngine::GetMaxFds() << ""; data << "" << ServerInstance->startup_time << ""; data << ""; - const std::vector& isupport = ServerInstance->ISupport.GetLines(); - for (std::vector::const_iterator it = isupport.begin(); it != isupport.end(); it++) + const std::vector& isupport = ServerInstance->ISupport.GetLines(); + for (std::vector::const_iterator i = isupport.begin(); i != isupport.end(); ++i) { - data << Sanitize(*it) << std::endl; + const Numeric::Numeric& num = *i; + for (std::vector::const_iterator j = num.GetParams().begin(); j != num.GetParams().end()-1; ++j) + data << "" << Sanitize(*j) << "" << std::endl; } data << ""; std::vector xltypes = ServerInstance->XLines->GetAllTypes(); @@ -182,13 +183,13 @@ class ModuleHttpStats : public Module data << ""; data << "" << u->nick << "" << u->uuid << "" - << u->host << "" << u->dhost << "" - << Sanitize(u->fullname) << "" << u->server->GetName() << ""; + << u->GetRealHost() << "" << u->GetDisplayedHost() << "" + << Sanitize(u->GetRealName()) << "" << u->server->GetName() << ""; if (u->IsAway()) data << "" << Sanitize(u->awaymsg) << "" << u->awaytime << ""; if (u->IsOper()) data << "" << Sanitize(u->oper->name) << ""; - data << "" << u->FormatModes() << "" << Sanitize(u->ident) << ""; + data << "" << u->GetModeLetters().substr(1) << "" << Sanitize(u->ident) << ""; LocalUser* lu = IS_LOCAL(u); if (lu) data << "" << lu->GetServerPort() << "" @@ -210,7 +211,7 @@ class ModuleHttpStats : public Module data << ""; data << "" << b->servername << ""; data << "" << b->parentname << ""; - data << "" << b->gecos << ""; + data << "" << Sanitize(b->description) << ""; data << "" << b->usercount << ""; // This is currently not implemented, so, commented out. // data << "" << b->opercount << ""; @@ -218,20 +219,35 @@ class ModuleHttpStats : public Module data << ""; } - data << ""; + data << ""; + + const CommandParser::CommandMap& commands = ServerInstance->Parser.GetCommands(); + for (CommandParser::CommandMap::const_iterator i = commands.begin(); i != commands.end(); ++i) + { + data << "" << i->second->name << "" << i->second->use_count << ""; + } + + data << ""; /* Send the document back to m_httpd */ HTTPDocumentResponse response(this, *http, &data, 200); response.headers.SetHeader("X-Powered-By", MODNAME); response.headers.SetHeader("Content-Type", "text/xml"); API->SendResponse(response); + return MOD_RES_DENY; // Handled } } + return MOD_RES_PASSTHRU; + } + + ModResult OnHTTPRequest(HTTPRequest& req) CXX11_OVERRIDE + { + return HandleRequest(&req); } Version GetVersion() CXX11_OVERRIDE { - return Version("Provides statistics over HTTP via m_httpd.so", VF_VENDOR); + return Version("Provides statistics over HTTP via m_httpd", VF_VENDOR); } };