X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_httpd_config.cpp;h=6fd7f405013e6fcc22092bd4c32ac5833bb5712b;hb=1e68ff30df59dc1e063a678134705d177b2e4562;hp=f79f0c2a4a1f0cb7e4496b7987aaa02806990eeb;hpb=9d4004e8d477232c143830508a7a6e41fd2d31b7;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_httpd_config.cpp b/src/modules/m_httpd_config.cpp index f79f0c2a4..6fd7f4050 100644 --- a/src/modules/m_httpd_config.cpp +++ b/src/modules/m_httpd_config.cpp @@ -1,28 +1,35 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2009-2010 Daniel De Graaf + * Copyright (C) 2008 Craig Edwards * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#include "inspircd.h" -#include "httpd.h" -#include "protocol.h" -/* $ModDesc: Provides statistics over HTTP via m_httpd.so */ +#include "inspircd.h" +#include "modules/httpd.h" -class ModuleHttpConfig : public Module +class ModuleHttpConfig : public Module, public HTTPRequestEventListener { + HTTPdAPI API; + public: - ModuleHttpConfig() { - Implementation eventlist[] = { I_OnEvent }; - ServerInstance->Modules->Attach(eventlist, this, 1); + ModuleHttpConfig() + : HTTPRequestEventListener(this) + , API(this) + { } std::string Sanitize(const std::string &str) @@ -59,14 +66,12 @@ class ModuleHttpConfig : public Module return ret; } - void OnEvent(Event& event) + ModResult HandleRequest(HTTPRequest* http) { std::stringstream data(""); - if (event.id == "httpd_url") { - ServerInstance->Logs->Log("m_http_stats", DEBUG,"Handling httpd event"); - HTTPRequest* http = (HTTPRequest*)&event; + ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Handling httpd event"); if ((http->GetURI() == "/config") || (http->GetURI() == "/config/")) { @@ -87,20 +92,23 @@ class ModuleHttpConfig : public Module data << ""; /* 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); + return MOD_RES_DENY; // Handled } } + return MOD_RES_PASSTHRU; } - virtual ~ModuleHttpConfig() + ModResult OnHTTPRequest(HTTPRequest& req) CXX11_OVERRIDE { + return HandleRequest(&req); } - 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); } };