]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_httpd_config.cpp
Merge pull request #959 from Alef-Burzmali/master+fixcloaking
[user/henk/code/inspircd.git] / src / modules / m_httpd_config.cpp
index aa84b83a48521f609a2203b73d650af080254d8f..3c468079925a3ca0cc16c93548fc2316129546e0 100644 (file)
 
 
 #include "inspircd.h"
-#include "httpd.h"
-#include "protocol.h"
-
-/* $ModDesc: Provides statistics over HTTP via m_httpd.so */
+#include "modules/httpd.h"
 
 class ModuleHttpConfig : public Module
 {
+       HTTPdAPI API;
+
  public:
-       ModuleHttpConfig()      {
-               Implementation eventlist[] = { I_OnEvent };
-               ServerInstance->Modules->Attach(eventlist, this, 1);
+       ModuleHttpConfig()
+               : API(this)
+       {
        }
 
        std::string Sanitize(const std::string &str)
@@ -66,13 +65,13 @@ class ModuleHttpConfig : public Module
                return ret;
        }
 
-       void OnEvent(Event& event)
+       void OnEvent(Event& event) CXX11_OVERRIDE
        {
                std::stringstream data("");
 
                if (event.id == "httpd_url")
                {
-                       ServerInstance->Logs->Log("m_http_stats", DEBUG,"Handling httpd event");
+                       ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Handling httpd event");
                        HTTPRequest* http = (HTTPRequest*)&event;
 
                        if ((http->GetURI() == "/config") || (http->GetURI() == "/config/"))
@@ -94,20 +93,16 @@ class ModuleHttpConfig : public Module
                                data << "</body></html>";
                                /* Send the document back to m_httpd */
                                HTTPDocumentResponse response(this, *http, &data, 200);
-                               response.headers.SetHeader("X-Powered-By", "m_httpd_config.so");
+                               response.headers.SetHeader("X-Powered-By", MODNAME);
                                response.headers.SetHeader("Content-Type", "text/html");
-                               response.Send();
+                               API->SendResponse(response);
                        }
                }
        }
 
-       virtual ~ModuleHttpConfig()
-       {
-       }
-
-       virtual Version GetVersion()
+       Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Provides configuration over HTTP via m_httpd.so", VF_VENDOR);
+               return Version("Allows for the server configuration to be viewed over HTTP via m_httpd.so", VF_VENDOR);
        }
 };