summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-05-12 19:26:52 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-05-12 19:26:52 +0000
commitb3bcd98242b8764f52bcde3259d7bc0ef72f61e3 (patch)
treefcc9a0b8a6a8b02a10f46af165f62c98d1d79afe /src
parentdfdbcc2939dff8311bd38046f6be518021bcede1 (diff)
Flesh this out some more
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9710 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_httpd_acl.cpp71
1 files changed, 70 insertions, 1 deletions
diff --git a/src/modules/m_httpd_acl.cpp b/src/modules/m_httpd_acl.cpp
index e16874bb4..18270507c 100644
--- a/src/modules/m_httpd_acl.cpp
+++ b/src/modules/m_httpd_acl.cpp
@@ -14,21 +14,73 @@
#include "inspircd.h"
#include "httpd.h"
#include "protocol.h"
+#include "wildcard.h"
/* $ModDesc: Provides access control lists (passwording of resources, ip restrictions etc) to m_httpd.so dependent modules */
/* $ModDep: httpd.h */
+class ACL : public Extensible
+{
+ public:
+ std::string path;
+ std::string password;
+ std::string whitelist;
+ std::string blacklist;
+
+ ACL(const std::string &set_path, const std::string &set_password,
+ const std::string &set_whitelist, const std::string &set_blacklist)
+ : path(set_path), password(set_password), whitelist(set_whitelist),
+ blacklist(set_blacklist) { }
+
+ ~ACL() { }
+};
+
class ModuleHTTPAccessList : public Module
{
std::string stylesheet;
bool changed;
+ std::vector<ACL> acl_list;
public:
void ReadConfig()
{
+ acl_list.clear();
ConfigReader c(ServerInstance);
+ int n_items = c.Enumerate("httpacl");
+ for (int i = 0; i < n_items; ++i)
+ {
+ std::string path = c.ReadValue("httpacl", "path", i);
+ std::string types = c.ReadValue("httpacl", "types", i);
+ irc::commasepstream sep(types);
+ std::string type;
+ std::string password;
+ std::string whitelist;
+ std::string blacklist;
+
+ while (sep.GetToken(type))
+ {
+ if (type == "password")
+ {
+ password = c.ReadValue("httpacl", "password", i);
+ }
+ else if (type == "whitelist")
+ {
+ whitelist = c.ReadValue("httpacl", "whitelist", i);
+ }
+ else if (type == "blacklist")
+ {
+ blacklist = c.ReadValue("httpacl", "blacklist", i);
+ }
+ else
+ {
+ throw ModuleException("Invalid HTTP ACL type '" + type + "'");
+ }
+ }
+
+ acl_list.push_back(ACL(path, password, whitelist, blacklist));
+ }
}
ModuleHTTPAccessList(InspIRCd* Me) : Module(Me)
@@ -48,7 +100,24 @@ class ModuleHTTPAccessList : public Module
ServerInstance->Logs->Log("m_http_stats", DEBUG,"Handling httpd event");
HTTPRequest* http = (HTTPRequest*)event->GetData();
-
+ for (std::vector<ACL>::const_iterator this_acl = acl_list.begin(); this_acl != acl_list.end(); ++this_acl)
+ {
+ if (match(http->GetURI(), this_acl->path))
+ {
+ if (!this_acl->blacklist.empty())
+ {
+ /* Blacklist */
+ }
+ if (!this_acl->whitelist.empty())
+ {
+ /* Whitelist */
+ }
+ if (!this_acl->password.empty())
+ {
+ /* Password auth */
+ }
+ }
+ }
//if ((http->GetURI() == "/stats") || (http->GetURI() == "/stats/"))
//{