From dfdbcc2939dff8311bd38046f6be518021bcede1 Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 12 May 2008 19:06:36 +0000 Subject: [PATCH 1/1] Skeleton ACL module, and hooks for it. This will provide ip restrictions, passwording etc for httpd modules git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9709 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/httpd.h | 3 +- src/modules/m_httpd.cpp | 13 ++++-- src/modules/m_httpd_acl.cpp | 80 +++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 src/modules/m_httpd_acl.cpp diff --git a/src/modules/httpd.h b/src/modules/httpd.h index a1eff6b63..0fa5c09d5 100644 --- a/src/modules/httpd.h +++ b/src/modules/httpd.h @@ -109,7 +109,8 @@ class HTTPRequest : public classbase public: HTTPHeaders *headers; - + int errorcode; + /** A socket pointer, which you must return in your HTTPDocument class * if you reply to this request. */ diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index eff9a7ad2..ee4544371 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -339,12 +339,17 @@ class HttpServerSocket : public BufferedSocket { claimed = false; HTTPRequest httpr(request_type,uri,&headers,this,this->GetIP(),postdata); - Event e((char*)&httpr, (Module*)HttpModule, "httpd_url"); - e.Send(this->Instance); + Event acl((char*)&httpr, (Module*)HttpModule, "httpd_acl"); + acl.Send(this->Instance); if (!claimed) { - SendHTTPError(404); - Instance->SE->WantWrite(this); + Event e((char*)&httpr, (Module*)HttpModule, "httpd_url"); + e.Send(this->Instance); + if (!claimed) + { + SendHTTPError(404); + Instance->SE->WantWrite(this); + } } } } diff --git a/src/modules/m_httpd_acl.cpp b/src/modules/m_httpd_acl.cpp new file mode 100644 index 000000000..e16874bb4 --- /dev/null +++ b/src/modules/m_httpd_acl.cpp @@ -0,0 +1,80 @@ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2008 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#include "inspircd.h" +#include "httpd.h" +#include "protocol.h" + +/* $ModDesc: Provides access control lists (passwording of resources, ip restrictions etc) to m_httpd.so dependent modules */ +/* $ModDep: httpd.h */ + +class ModuleHTTPAccessList : public Module +{ + + std::string stylesheet; + bool changed; + + public: + + void ReadConfig() + { + ConfigReader c(ServerInstance); + } + + ModuleHTTPAccessList(InspIRCd* Me) : Module(Me) + { + ReadConfig(); + this->changed = true; + Implementation eventlist[] = { I_OnEvent, I_OnRequest }; + ServerInstance->Modules->Attach(eventlist, this, 2); + } + + void OnEvent(Event* event) + { + std::stringstream data(""); + + if (event->GetEventID() == "httpd_url") + { + ServerInstance->Logs->Log("m_http_stats", DEBUG,"Handling httpd event"); + HTTPRequest* http = (HTTPRequest*)event->GetData(); + + + + //if ((http->GetURI() == "/stats") || (http->GetURI() == "/stats/")) + //{ + /* Send the document back to m_httpd */ + // HTTPDocument response(http->sock, &data, 200); + // response.headers.SetHeader("X-Powered-By", "m_httpd_stats.so"); + // response.headers.SetHeader("Content-Type", "text/xml"); + // Request req((char*)&response, (Module*)this, event->GetSource()); + // req.Send(); + //} + } + } + + const char* OnRequest(Request* request) + { + return NULL; + } + + virtual ~ModuleHTTPAccessList() + { + } + + virtual Version GetVersion() + { + return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION); + } +}; + +MODULE_INIT(ModuleHTTPAccessList) -- 2.39.2