]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Skeleton ACL module, and hooks for it. This will provide ip restrictions, passwording...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 12 May 2008 19:06:36 +0000 (19:06 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 12 May 2008 19:06:36 +0000 (19:06 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9709 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/httpd.h
src/modules/m_httpd.cpp
src/modules/m_httpd_acl.cpp [new file with mode: 0644]

index a1eff6b638e798acbf75c8a01f4beac8902d9db6..0fa5c09d55f551b7355b8605362e2503802a31f6 100644 (file)
@@ -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.
         */
index eff9a7ad238f38f7423cf328a98c3a46738550f1..ee45443715baaa172c42b8cf2668d7a8b2cfb28f 100644 (file)
@@ -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 (file)
index 0000000..e16874b
--- /dev/null
@@ -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)