summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-05-12 19:06:36 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-05-12 19:06:36 +0000
commitdfdbcc2939dff8311bd38046f6be518021bcede1 (patch)
treee364116c8e8663af1b86d7b5821b8c4653f2a42b
parent46f43132aadf89cbb362803335018bd96e0ab4dc (diff)
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
-rw-r--r--src/modules/httpd.h3
-rw-r--r--src/modules/m_httpd.cpp13
-rw-r--r--src/modules/m_httpd_acl.cpp80
3 files changed, 91 insertions, 5 deletions
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)