X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_httpd_stats.cpp;h=eb8e856acde4e150e28aab4917c916ed18673a31;hb=3b78613576364c4ac6a4e4af43a2eea056c8dd3f;hp=30eacd7a725915b70ee5fec84600ac6b24ec18bd;hpb=7010a92426d2c3ab0cea5ba0d36a04bc6b52349f;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index 30eacd7a7..eb8e856ac 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,14 +88,12 @@ 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/")) { @@ -107,19 +106,15 @@ class ModuleHttpStats : public Module data << "" << ServerInstance->GetChans().size() << ""; data << "" << ServerInstance->Users->all_opers.size() << ""; data << "" << (SocketEngine::GetUsedFds()) << "" << SocketEngine::GetMaxFds() << "" INSPIRCD_SOCKETENGINE_NAME ""; - - time_t current_time = 0; - current_time = ServerInstance->Time(); - time_t server_uptime = current_time - ServerInstance->startup_time; - struct tm* stime; - stime = gmtime(&server_uptime); - data << "" << stime->tm_yday << "" << stime->tm_hour << "" << stime->tm_min << "" << stime->tm_sec << "" << ServerInstance->startup_time << ""; + 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(); @@ -189,7 +184,7 @@ class ModuleHttpStats : public Module data << ""; data << "" << u->nick << "" << u->uuid << "" << u->host << "" << u->dhost << "" - << Sanitize(u->fullname) << "" << u->server << ""; + << Sanitize(u->fullname) << "" << u->server->GetName() << ""; if (u->IsAway()) data << "" << Sanitize(u->awaymsg) << "" << u->awaytime << ""; if (u->IsOper()) @@ -224,15 +219,30 @@ 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