mirror of
https://github.com/anope/anope.git
synced 2026-06-12 19:14:47 +02:00
Move HTTP types to the HTTP namespace.
This commit is contained in:
+55
-30
@@ -8,28 +8,39 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
enum HTTPError
|
||||
namespace HTTP
|
||||
{
|
||||
HTTP_ERROR_OK = 200,
|
||||
HTTP_FOUND = 302,
|
||||
HTTP_BAD_REQUEST = 400,
|
||||
HTTP_PAGE_NOT_FOUND = 404,
|
||||
HTTP_NOT_SUPPORTED = 505
|
||||
};
|
||||
class Reply;
|
||||
class Message;
|
||||
class Page;
|
||||
class Client;
|
||||
class Provider;
|
||||
|
||||
enum Error
|
||||
{
|
||||
OK = 200,
|
||||
FOUND = 302,
|
||||
BAD_REQUEST = 400,
|
||||
PAGE_NOT_FOUND = 404,
|
||||
NOT_SUPPORTED = 505,
|
||||
};
|
||||
}
|
||||
|
||||
/* A message to someone */
|
||||
struct HTTPReply final
|
||||
struct HTTP::Reply final
|
||||
{
|
||||
HTTPError error = HTTP_ERROR_OK;
|
||||
HTTP::Error error = HTTP::OK;
|
||||
Anope::string content_type;
|
||||
std::map<Anope::string, Anope::string, ci::less> headers;
|
||||
typedef std::list<std::pair<Anope::string, Anope::string> > cookie;
|
||||
std::vector<cookie> cookies;
|
||||
|
||||
HTTPReply() = default;
|
||||
HTTPReply &operator=(const HTTPReply &) = default;
|
||||
Reply() = default;
|
||||
Reply &operator=(const HTTP::Reply &) = default;
|
||||
|
||||
HTTPReply(const HTTPReply &other) : error(other.error), length(other.length)
|
||||
Reply(const HTTP::Reply &other)
|
||||
: error(other.error)
|
||||
, length(other.length)
|
||||
{
|
||||
content_type = other.content_type;
|
||||
headers = other.headers;
|
||||
@@ -39,7 +50,7 @@ struct HTTPReply final
|
||||
out.push_back(new Data(datum->buf, datum->len));
|
||||
}
|
||||
|
||||
~HTTPReply()
|
||||
~Reply()
|
||||
{
|
||||
for (const auto *datum : out)
|
||||
delete datum;
|
||||
@@ -81,7 +92,7 @@ struct HTTPReply final
|
||||
};
|
||||
|
||||
/* A message from someone */
|
||||
struct HTTPMessage final
|
||||
struct HTTP::Message final
|
||||
{
|
||||
std::map<Anope::string, Anope::string, ci::less> headers;
|
||||
std::map<Anope::string, Anope::string, ci::less> cookies;
|
||||
@@ -90,17 +101,18 @@ struct HTTPMessage final
|
||||
Anope::string content;
|
||||
};
|
||||
|
||||
class HTTPClient;
|
||||
class HTTPProvider;
|
||||
|
||||
class HTTPPage
|
||||
class HTTP::Page
|
||||
: public virtual Base
|
||||
{
|
||||
Anope::string url;
|
||||
Anope::string content_type;
|
||||
|
||||
public:
|
||||
HTTPPage(const Anope::string &u, const Anope::string &ct = "text/html") : url(u), content_type(ct) { }
|
||||
Page(const Anope::string &u, const Anope::string &ct = "text/html")
|
||||
: url(u)
|
||||
, content_type(ct)
|
||||
{
|
||||
}
|
||||
|
||||
const Anope::string &GetURL() const { return this->url; }
|
||||
|
||||
@@ -113,10 +125,10 @@ public:
|
||||
* @param The HTTP header sent from the client to request the page
|
||||
* @param The HTTP header that will be sent back to the client
|
||||
*/
|
||||
virtual bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) = 0;
|
||||
virtual bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &) = 0;
|
||||
};
|
||||
|
||||
class HTTPClient
|
||||
class HTTP::Client
|
||||
: public ClientSocket
|
||||
, public BinarySocket
|
||||
, public Base
|
||||
@@ -128,18 +140,24 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
HTTPClient(ListenSocket *l, int f, const sockaddrs &a) : ClientSocket(l, a), BinarySocket() { }
|
||||
Client(ListenSocket *l, int f, const sockaddrs &a)
|
||||
: ClientSocket(l, a)
|
||||
, BinarySocket()
|
||||
{
|
||||
}
|
||||
|
||||
virtual const Anope::string GetIP()
|
||||
{
|
||||
return this->clientaddr.addr();
|
||||
}
|
||||
|
||||
virtual void SendError(HTTPError err, const Anope::string &msg) = 0;
|
||||
virtual void SendReply(HTTPReply *) = 0;
|
||||
virtual void SendError(HTTP::Error err, const Anope::string &msg) = 0;
|
||||
virtual void SendReply(HTTP::Reply *) = 0;
|
||||
};
|
||||
|
||||
class HTTPProvider
|
||||
#define HTTP_PROVIDER "HTTP::Provider"
|
||||
|
||||
class HTTP::Provider
|
||||
: public ListenSocket
|
||||
, public Service
|
||||
{
|
||||
@@ -150,7 +168,14 @@ public:
|
||||
std::vector<Anope::string> ext_ips;
|
||||
std::vector<Anope::string> ext_headers;
|
||||
|
||||
HTTPProvider(Module *c, const Anope::string &n, const Anope::string &i, const unsigned short p, bool s) : ListenSocket(i, p, i.find(':') != Anope::string::npos), Service(c, "HTTPProvider", n), ip(i), port(p), ssl(s) { }
|
||||
Provider(Module *c, const Anope::string &n, const Anope::string &i, const unsigned short p, bool s)
|
||||
: ListenSocket(i, p, i.find(':') != Anope::string::npos)
|
||||
, Service(c, HTTP_PROVIDER, n)
|
||||
, ip(i)
|
||||
, port(p)
|
||||
, ssl(s)
|
||||
{
|
||||
}
|
||||
|
||||
const Anope::string &GetIP() const
|
||||
{
|
||||
@@ -167,12 +192,12 @@ public:
|
||||
return this->ssl;
|
||||
}
|
||||
|
||||
virtual bool RegisterPage(HTTPPage *page) = 0;
|
||||
virtual void UnregisterPage(HTTPPage *page) = 0;
|
||||
virtual HTTPPage *FindPage(const Anope::string &name) = 0;
|
||||
virtual bool RegisterPage(HTTP::Page *page) = 0;
|
||||
virtual void UnregisterPage(HTTP::Page *page) = 0;
|
||||
virtual HTTP::Page *FindPage(const Anope::string &name) = 0;
|
||||
};
|
||||
|
||||
namespace HTTPUtils
|
||||
namespace HTTP
|
||||
{
|
||||
inline Anope::string URLDecode(const Anope::string &url)
|
||||
{
|
||||
|
||||
@@ -148,9 +148,9 @@ public:
|
||||
Anope::string name;
|
||||
Anope::string id;
|
||||
std::deque<Anope::string> data;
|
||||
HTTPReply &reply;
|
||||
HTTP::Reply &reply;
|
||||
|
||||
Request(HTTPReply &r)
|
||||
Request(HTTP::Reply &r)
|
||||
: reply(r)
|
||||
{
|
||||
}
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
|
||||
const auto &GetMinParams() const { return minparams; }
|
||||
|
||||
virtual bool Run(ServiceInterface *iface, HTTPClient *client, Request &request) = 0;
|
||||
virtual bool Run(ServiceInterface *iface, HTTP::Client *client, Request &request) = 0;
|
||||
};
|
||||
|
||||
struct RPC::Token final
|
||||
|
||||
@@ -20,10 +20,10 @@ template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
|
||||
|
||||
class XMLRPCServiceInterface final
|
||||
: public RPC::ServiceInterface
|
||||
, public HTTPPage
|
||||
, public HTTP::Page
|
||||
{
|
||||
private:
|
||||
static void SendError(HTTPReply &reply, xmlrpc_env &env)
|
||||
static void SendError(HTTP::Reply &reply, xmlrpc_env &env)
|
||||
{
|
||||
Log(LOG_DEBUG) << "XML-RPC error " << env.fault_code << ": " << env.fault_string;
|
||||
|
||||
@@ -69,11 +69,11 @@ public:
|
||||
|
||||
XMLRPCServiceInterface(Module *creator)
|
||||
: RPC::ServiceInterface(creator)
|
||||
, HTTPPage("/xmlrpc", "text/xml")
|
||||
, HTTP::Page("/xmlrpc", "text/xml")
|
||||
{
|
||||
}
|
||||
|
||||
bool OnRequest(HTTPProvider *provider, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) override
|
||||
bool OnRequest(HTTP::Provider *provider, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply) override
|
||||
{
|
||||
xmlrpc_env env;
|
||||
xmlrpc_env_init(&env);
|
||||
@@ -276,7 +276,7 @@ class ModuleXMLRPC final
|
||||
: public Module
|
||||
{
|
||||
private:
|
||||
ServiceReference<HTTPProvider> httpref;
|
||||
ServiceReference<HTTP::Provider> httpref;
|
||||
XMLRPCServiceInterface xmlrpcinterface;
|
||||
|
||||
public:
|
||||
@@ -316,7 +316,7 @@ public:
|
||||
XMLRPCServiceInterface::enable_i8 = modconf.Get<bool>("enable_i8", "yes");
|
||||
XMLRPCServiceInterface::enable_nil = modconf.Get<bool>("enable_nil", "yes");
|
||||
|
||||
this->httpref = ServiceReference<HTTPProvider>("HTTPProvider", modconf.Get<const Anope::string>("server", "httpd/main"));
|
||||
this->httpref = ServiceReference<HTTP::Provider>(HTTP_PROVIDER, modconf.Get<const Anope::string>("server", "httpd/main"));
|
||||
if (!httpref)
|
||||
throw ConfigException("Unable to find http reference, is httpd loaded?");
|
||||
|
||||
|
||||
+27
-27
@@ -18,19 +18,19 @@ static Anope::string BuildDate()
|
||||
return timebuf;
|
||||
}
|
||||
|
||||
static Anope::string GetStatusFromCode(HTTPError err)
|
||||
static Anope::string GetStatusFromCode(HTTP::Error err)
|
||||
{
|
||||
switch (err)
|
||||
{
|
||||
case HTTP_ERROR_OK:
|
||||
case HTTP::OK:
|
||||
return "200 OK";
|
||||
case HTTP_FOUND:
|
||||
case HTTP::FOUND:
|
||||
return "302 Found";
|
||||
case HTTP_BAD_REQUEST:
|
||||
case HTTP::BAD_REQUEST:
|
||||
return "400 Bad Request";
|
||||
case HTTP_PAGE_NOT_FOUND:
|
||||
case HTTP::PAGE_NOT_FOUND:
|
||||
return "404 Not Found";
|
||||
case HTTP_NOT_SUPPORTED:
|
||||
case HTTP::NOT_SUPPORTED:
|
||||
return "505 HTTP Version Not Supported";
|
||||
}
|
||||
|
||||
@@ -38,13 +38,13 @@ static Anope::string GetStatusFromCode(HTTPError err)
|
||||
}
|
||||
|
||||
class MyHTTPClient final
|
||||
: public HTTPClient
|
||||
: public HTTP::Client
|
||||
{
|
||||
HTTPProvider *provider;
|
||||
HTTPMessage message;
|
||||
HTTP::Provider *provider;
|
||||
HTTP::Message message;
|
||||
bool header_done = false, served = false;
|
||||
Anope::string page_name;
|
||||
Reference<HTTPPage> page;
|
||||
Reference<HTTP::Page> page;
|
||||
Anope::string ip;
|
||||
|
||||
unsigned content_length = 0;
|
||||
@@ -64,7 +64,7 @@ class MyHTTPClient final
|
||||
|
||||
if (!this->page)
|
||||
{
|
||||
this->SendError(HTTP_PAGE_NOT_FOUND, "Page not found");
|
||||
this->SendError(HTTP::PAGE_NOT_FOUND, "Page not found");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class MyHTTPClient final
|
||||
|
||||
Log(LOG_DEBUG, "httpd") << "httpd: Serving page " << this->page_name << " to " << this->ip;
|
||||
|
||||
HTTPReply reply;
|
||||
HTTP::Reply reply;
|
||||
reply.content_type = this->page->GetContentType();
|
||||
|
||||
if (this->page->OnRequest(this->provider, this->page_name, this, this->message, reply))
|
||||
@@ -93,7 +93,7 @@ class MyHTTPClient final
|
||||
public:
|
||||
time_t created;
|
||||
|
||||
MyHTTPClient(HTTPProvider *l, int f, const sockaddrs &a) : Socket(f, l->GetFamily()), HTTPClient(l, f, a), provider(l), ip(a.addr()), created(Anope::CurTime)
|
||||
MyHTTPClient(HTTP::Provider *l, int f, const sockaddrs &a) : Socket(f, l->GetFamily()), HTTP::Client(l, f, a), provider(l), ip(a.addr()), created(Anope::CurTime)
|
||||
{
|
||||
Log(LOG_DEBUG, "httpd") << "Accepted connection " << f << " from " << a.addr();
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public:
|
||||
size_t sz = token.find('=');
|
||||
if (sz == Anope::string::npos || !sz || sz + 1 >= token.length())
|
||||
continue;
|
||||
this->message.post_data[token.substr(0, sz)] = HTTPUtils::URLDecode(token.substr(sz + 1));
|
||||
this->message.post_data[token.substr(0, sz)] = HTTP::URLDecode(token.substr(sz + 1));
|
||||
Log(LOG_DEBUG_2) << "HTTP POST from " << this->clientaddr.addr() << ": " << token.substr(0, sz) << ": " << this->message.post_data[token.substr(0, sz)];
|
||||
}
|
||||
|
||||
@@ -163,13 +163,13 @@ public:
|
||||
|
||||
if (params.empty() || (params[0] != "GET" && params[0] != "POST"))
|
||||
{
|
||||
this->SendError(HTTP_BAD_REQUEST, "Unknown operation");
|
||||
this->SendError(HTTP::BAD_REQUEST, "Unknown operation");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (params.size() != 3)
|
||||
{
|
||||
this->SendError(HTTP_BAD_REQUEST, "Invalid parameters");
|
||||
this->SendError(HTTP::BAD_REQUEST, "Invalid parameters");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
size_t sz = token.find('=');
|
||||
if (sz == Anope::string::npos || !sz || sz + 1 >= token.length())
|
||||
continue;
|
||||
this->message.get_data[token.substr(0, sz)] = HTTPUtils::URLDecode(token.substr(sz + 1));
|
||||
this->message.get_data[token.substr(0, sz)] = HTTP::URLDecode(token.substr(sz + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,9 +229,9 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void SendError(HTTPError err, const Anope::string &msg) override
|
||||
void SendError(HTTP::Error err, const Anope::string &msg) override
|
||||
{
|
||||
HTTPReply h;
|
||||
HTTP::Reply h;
|
||||
|
||||
h.error = err;
|
||||
|
||||
@@ -240,7 +240,7 @@ public:
|
||||
this->SendReply(&h);
|
||||
}
|
||||
|
||||
void SendReply(HTTPReply *msg) override
|
||||
void SendReply(HTTP::Reply *msg) override
|
||||
{
|
||||
this->WriteClient("HTTP/1.1 " + GetStatusFromCode(msg->error));
|
||||
this->WriteClient("Date: " + BuildDate());
|
||||
@@ -281,17 +281,17 @@ public:
|
||||
};
|
||||
|
||||
class MyHTTPProvider final
|
||||
: public HTTPProvider
|
||||
: public HTTP::Provider
|
||||
, public Timer
|
||||
{
|
||||
int timeout;
|
||||
std::map<Anope::string, HTTPPage *> pages;
|
||||
std::map<Anope::string, HTTP::Page *> pages;
|
||||
std::list<Reference<MyHTTPClient> > clients;
|
||||
|
||||
public:
|
||||
MyHTTPProvider(Module *c, const Anope::string &n, const Anope::string &i, const unsigned short p, const int t, bool s)
|
||||
: Socket(-1, i.find(':') == Anope::string::npos ? AF_INET : AF_INET6)
|
||||
, HTTPProvider(c, n, i, p, s)
|
||||
, HTTP::Provider(c, n, i, p, s)
|
||||
, Timer(c, 10, true)
|
||||
, timeout(t)
|
||||
{
|
||||
@@ -317,17 +317,17 @@ public:
|
||||
return c;
|
||||
}
|
||||
|
||||
bool RegisterPage(HTTPPage *page) override
|
||||
bool RegisterPage(HTTP::Page *page) override
|
||||
{
|
||||
return this->pages.emplace(page->GetURL(), page).second;
|
||||
}
|
||||
|
||||
void UnregisterPage(HTTPPage *page) override
|
||||
void UnregisterPage(HTTP::Page *page) override
|
||||
{
|
||||
this->pages.erase(page->GetURL());
|
||||
}
|
||||
|
||||
HTTPPage *FindPage(const Anope::string &pname) override
|
||||
HTTP::Page *FindPage(const Anope::string &pname) override
|
||||
{
|
||||
if (this->pages.count(pname) == 0)
|
||||
return NULL;
|
||||
@@ -443,7 +443,7 @@ public:
|
||||
|
||||
for (std::map<Anope::string, MyHTTPProvider *>::iterator it = this->providers.begin(), it_end = this->providers.end(); it != it_end;)
|
||||
{
|
||||
HTTPProvider *p = it->second;
|
||||
HTTP::Provider *p = it->second;
|
||||
++it;
|
||||
|
||||
if (existing.count(p->name) == 0)
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace
|
||||
if (split == Anope::string::npos)
|
||||
res = modmap.emplace(datapair, "");
|
||||
else
|
||||
res = modmap.emplace(datapair.substr(0, split), HTTPUtils::URLDecode(datapair.substr(split + 1)));
|
||||
res = modmap.emplace(datapair.substr(0, split), HTTP::URLDecode(datapair.substr(split + 1)));
|
||||
|
||||
if (Anope::ProtocolDebug && res.second)
|
||||
Log(LOG_DEBUG) << "Parsed module data: key=" << res.first->first << " value=" << res.first->second;
|
||||
|
||||
@@ -23,7 +23,7 @@ inline Anope::string yyjson_get_astr(yyjson_val *val, const char *key)
|
||||
|
||||
class JSONRPCServiceInterface final
|
||||
: public RPC::ServiceInterface
|
||||
, public HTTPPage
|
||||
, public HTTP::Page
|
||||
{
|
||||
private:
|
||||
static std::pair<yyjson_mut_doc *, yyjson_mut_val *> CreateReply(const Anope::string &id)
|
||||
@@ -43,7 +43,7 @@ private:
|
||||
return { doc, root };
|
||||
}
|
||||
|
||||
static void SendError(HTTPReply &reply, int64_t code, const Anope::string &message, const Anope::string &id = "")
|
||||
static void SendError(HTTP::Reply &reply, int64_t code, const Anope::string &message, const Anope::string &id = "")
|
||||
{
|
||||
Log(LOG_DEBUG) << "JSON-RPC error " << code << ": " << message;
|
||||
|
||||
@@ -91,11 +91,11 @@ public:
|
||||
|
||||
JSONRPCServiceInterface(Module *creator)
|
||||
: RPC::ServiceInterface(creator)
|
||||
, HTTPPage("/jsonrpc", "application/json")
|
||||
, HTTP::Page("/jsonrpc", "application/json")
|
||||
{
|
||||
}
|
||||
|
||||
bool OnRequest(HTTPProvider *provider, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) override
|
||||
bool OnRequest(HTTP::Provider *provider, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply) override
|
||||
{
|
||||
yyjson_read_err error;
|
||||
const auto flags = YYJSON_READ_ALLOW_TRAILING_COMMAS | YYJSON_READ_ALLOW_INVALID_UNICODE;
|
||||
@@ -275,7 +275,7 @@ class ModuleJSONRPC final
|
||||
: public Module
|
||||
{
|
||||
private:
|
||||
ServiceReference<HTTPProvider> httpref;
|
||||
ServiceReference<HTTP::Provider> httpref;
|
||||
JSONRPCServiceInterface jsonrpcinterface;
|
||||
|
||||
public:
|
||||
@@ -299,7 +299,7 @@ public:
|
||||
const auto &modconf = conf.GetModule(this);
|
||||
JSONRPCServiceInterface::integer_bits = modconf.Get<unsigned>("integer_bits", "64");
|
||||
|
||||
this->httpref = ServiceReference<HTTPProvider>("HTTPProvider", modconf.Get<const Anope::string>("server", "httpd/main"));
|
||||
this->httpref = ServiceReference<HTTP::Provider>(HTTP_PROVIDER, modconf.Get<const Anope::string>("server", "httpd/main"));
|
||||
if (!httpref)
|
||||
throw ConfigException("Unable to find http reference, is httpd loaded?");
|
||||
|
||||
|
||||
+10
-10
@@ -139,7 +139,7 @@ public:
|
||||
users.Reply(u->nick);
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
|
||||
{
|
||||
const auto detail = request.data.empty() ? "name" : request.data[0];
|
||||
if (detail.equals_ci("name"))
|
||||
@@ -171,7 +171,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
|
||||
{
|
||||
auto *na = NickAlias::Find(request.data[0]);
|
||||
if (!na)
|
||||
@@ -249,7 +249,7 @@ public:
|
||||
users.Reply(uc->status.BuildModePrefixList() + uc->user->nick);
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
|
||||
{
|
||||
const auto detail = request.data.empty() ? "name" : request.data[0];
|
||||
if (detail.equals_ci("name"))
|
||||
@@ -281,7 +281,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
|
||||
{
|
||||
auto *c = Channel::Find(request.data[0]);
|
||||
if (!c)
|
||||
@@ -347,7 +347,7 @@ public:
|
||||
root.Reply("vhost", o->vhost);
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
|
||||
{
|
||||
const auto detail = request.data.empty() ? "name" : request.data[0];
|
||||
if (detail.equals_ci("name"))
|
||||
@@ -379,7 +379,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
|
||||
{
|
||||
auto *o = Oper::Find(request.data[0]);
|
||||
if (!o)
|
||||
@@ -425,7 +425,7 @@ public:
|
||||
root.Reply("uplink", nullptr);
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
|
||||
{
|
||||
const auto detail = request.data.empty() ? "name" : request.data[0];
|
||||
if (detail.equals_ci("name"))
|
||||
@@ -457,7 +457,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
|
||||
{
|
||||
auto *s = Server::Find(request.data[0]);
|
||||
if (!s)
|
||||
@@ -552,7 +552,7 @@ public:
|
||||
root.Reply("vident", u->GetIdent());
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
|
||||
{
|
||||
const auto detail = request.data.empty() ? "name" : request.data[0];
|
||||
if (detail.equals_ci("name"))
|
||||
@@ -584,7 +584,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
|
||||
{
|
||||
auto *u = User::Find(request.data[0]);
|
||||
if (!u)
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
|
||||
{
|
||||
if (!global)
|
||||
{
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
|
||||
{
|
||||
if (!global)
|
||||
{
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
|
||||
{
|
||||
auto *bi = BotInfo::Find(request.data[0], true);
|
||||
if (!bi)
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
|
||||
{
|
||||
// For both the map type and array type we test that we can handle:
|
||||
//
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool Run(RPC::ServiceInterface *iface, HTTPClient *client, RPC::Request &request) override
|
||||
bool Run(RPC::ServiceInterface *iface, HTTP::Client *client, RPC::Request &request) override
|
||||
{
|
||||
auto &root = request.Root<RPC::Array>();
|
||||
for (const auto &event : Service::GetServiceKeys(RPC_EVENT))
|
||||
|
||||
@@ -11,7 +11,7 @@ WebCPanel::ChanServ::Access::Access(const Anope::string &cat, const Anope::strin
|
||||
{
|
||||
}
|
||||
|
||||
bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
bool WebCPanel::ChanServ::Access::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
{
|
||||
TemplateFileServer Page("chanserv/access.html");
|
||||
const Anope::string &chname = message.get_data["channel"];
|
||||
@@ -95,7 +95,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s
|
||||
/* command might have invalidated u_access */
|
||||
u_access = ci->AccessFor(na->nc);
|
||||
|
||||
replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname);
|
||||
replacements["ESCAPED_CHANNEL"] = HTTP::URLEncode(chname);
|
||||
replacements["ACCESS_CHANGE"] = u_access.HasPriv("ACCESS_CHANGE") ? "YES" : "NO";
|
||||
|
||||
for (unsigned i = 0; i < ci->GetAccessCount(); ++i)
|
||||
|
||||
@@ -11,7 +11,7 @@ WebCPanel::ChanServ::Akick::Akick(const Anope::string &cat, const Anope::string
|
||||
{
|
||||
}
|
||||
|
||||
bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
bool WebCPanel::ChanServ::Akick::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
{
|
||||
const Anope::string &chname = message.get_data["channel"];
|
||||
TemplateFileServer Page("chanserv/akick.html");
|
||||
@@ -66,7 +66,7 @@ bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::st
|
||||
WebPanel::RunCommand(client, na->nc->display, na->nc, "ChanServ", "chanserv/akick", params, replacements);
|
||||
}
|
||||
|
||||
replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname);
|
||||
replacements["ESCAPED_CHANNEL"] = HTTP::URLEncode(chname);
|
||||
|
||||
for (unsigned i = 0; i < ci->GetAkickCount(); ++i)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ class WebCPanel::ChanServ::Access final
|
||||
{
|
||||
public:
|
||||
Access(const Anope::string &cat, const Anope::string &u);
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
std::set<Anope::string> GetData() override;
|
||||
};
|
||||
|
||||
@@ -33,7 +33,7 @@ class WebCPanel::ChanServ::Akick final
|
||||
{
|
||||
public:
|
||||
Akick(const Anope::string &cat, const Anope::string &u);
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
std::set<Anope::string> GetData() override;
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ class WebCPanel::ChanServ::Drop final
|
||||
{
|
||||
public:
|
||||
Drop(const Anope::string &cat, const Anope::string &u);
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
};
|
||||
|
||||
class WebCPanel::ChanServ::Info final
|
||||
@@ -50,7 +50,7 @@ class WebCPanel::ChanServ::Info final
|
||||
{
|
||||
public:
|
||||
Info(const Anope::string &cat, const Anope::string &u);
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
};
|
||||
|
||||
class WebCPanel::ChanServ::Modes final
|
||||
@@ -58,7 +58,7 @@ class WebCPanel::ChanServ::Modes final
|
||||
{
|
||||
public:
|
||||
Modes(const Anope::string &cat, const Anope::string &u);
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
std::set<Anope::string> GetData() override;
|
||||
};
|
||||
|
||||
@@ -67,6 +67,6 @@ class WebCPanel::ChanServ::Set final
|
||||
{
|
||||
public:
|
||||
Set(const Anope::string &cat, const Anope::string &u);
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
std::set<Anope::string> GetData() override;
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ WebCPanel::ChanServ::Drop::Drop(const Anope::string &cat, const Anope::string &u
|
||||
}
|
||||
|
||||
|
||||
bool WebCPanel::ChanServ::Drop::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
bool WebCPanel::ChanServ::Drop::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
{
|
||||
|
||||
if (message.post_data.count("channel") > 0 && message.post_data.count("confChan") > 0)
|
||||
@@ -20,7 +20,7 @@ bool WebCPanel::ChanServ::Drop::OnRequest(HTTPProvider *server, const Anope::str
|
||||
if (message.post_data["channel"] == message.post_data["confChan"])
|
||||
{
|
||||
std::vector<Anope::string> params;
|
||||
const Anope::string &channel = HTTPUtils::URLDecode(message.post_data["channel"]);
|
||||
const Anope::string &channel = HTTP::URLDecode(message.post_data["channel"]);
|
||||
params.push_back(channel);
|
||||
params.push_back(channel);
|
||||
|
||||
@@ -37,7 +37,7 @@ bool WebCPanel::ChanServ::Drop::OnRequest(HTTPProvider *server, const Anope::str
|
||||
if ((ci->HasExt("SECUREFOUNDER") ? ci->AccessFor(na->nc).founder : ci->AccessFor(na->nc).HasPriv("FOUNDER")) || (na->nc->IsServicesOper() && na->nc->o->ot->HasCommand("chanserv/drop")))
|
||||
{
|
||||
replacements["CHANNEL_NAMES"] = ci->name;
|
||||
replacements["ESCAPED_CHANNEL_NAMES"] = HTTPUtils::URLEncode(ci->name);
|
||||
replacements["ESCAPED_CHANNEL_NAMES"] = HTTP::URLEncode(ci->name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ bool WebCPanel::ChanServ::Drop::OnRequest(HTTPProvider *server, const Anope::str
|
||||
const Anope::string &chname = message.get_data["channel"];
|
||||
|
||||
replacements["CHANNEL_DROP"] = chname;
|
||||
replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname);
|
||||
replacements["ESCAPED_CHANNEL"] = HTTP::URLEncode(chname);
|
||||
}
|
||||
|
||||
TemplateFileServer page("chanserv/drop.html");
|
||||
|
||||
@@ -11,12 +11,12 @@ WebCPanel::ChanServ::Info::Info(const Anope::string &cat, const Anope::string &u
|
||||
{
|
||||
}
|
||||
|
||||
bool WebCPanel::ChanServ::Info::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
bool WebCPanel::ChanServ::Info::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
{
|
||||
const Anope::string &chname = message.get_data["channel"];
|
||||
|
||||
if (!chname.empty())
|
||||
replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname);
|
||||
replacements["ESCAPED_CHANNEL"] = HTTP::URLEncode(chname);
|
||||
|
||||
BuildChanList(na, replacements);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ WebCPanel::ChanServ::Modes::Modes(const Anope::string &cat, const Anope::string
|
||||
{
|
||||
}
|
||||
|
||||
bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
bool WebCPanel::ChanServ::Modes::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
{
|
||||
const Anope::string &chname = message.get_data["channel"];
|
||||
const Anope::string &mode = message.get_data["m"];
|
||||
@@ -25,7 +25,7 @@ bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::st
|
||||
return true;
|
||||
}
|
||||
|
||||
replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname);
|
||||
replacements["ESCAPED_CHANNEL"] = HTTP::URLEncode(chname);
|
||||
ChannelInfo *ci = ChannelInfo::Find(chname);
|
||||
|
||||
if (!ci)
|
||||
@@ -67,7 +67,7 @@ bool WebCPanel::ChanServ::Modes::OnRequest(HTTPProvider *server, const Anope::st
|
||||
Page.Serve(server, page_name, client, message, reply, replacements);
|
||||
return true;
|
||||
}
|
||||
replacements["ESCAPED_MODE"] = HTTPUtils::URLEncode(mode);
|
||||
replacements["ESCAPED_MODE"] = HTTP::URLEncode(mode);
|
||||
|
||||
ChannelMode *cm = ModeManager::FindChannelModeByChar(mode[0]);
|
||||
if (cm)
|
||||
|
||||
@@ -11,7 +11,7 @@ WebCPanel::ChanServ::Set::Set(const Anope::string &cat, const Anope::string &u)
|
||||
{
|
||||
}
|
||||
|
||||
bool WebCPanel::ChanServ::Set::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
bool WebCPanel::ChanServ::Set::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
{
|
||||
const Anope::string &chname = message.get_data["channel"];
|
||||
bool can_set = false;
|
||||
@@ -94,14 +94,14 @@ bool WebCPanel::ChanServ::Set::OnRequest(HTTPProvider *server, const Anope::stri
|
||||
}
|
||||
|
||||
replacements["CHANNEL"] = ci->name;
|
||||
replacements["CHANNEL_ESCAPED"] = HTTPUtils::URLEncode(ci->name);
|
||||
replacements["CHANNEL_ESCAPED"] = HTTP::URLEncode(ci->name);
|
||||
if (ci->GetFounder())
|
||||
replacements["FOUNDER"] = ci->GetFounder()->display;
|
||||
if (ci->GetSuccessor())
|
||||
replacements["SUCCESSOR"] = ci->GetSuccessor()->display;
|
||||
replacements["REGISTERED"] = Anope::strftime(ci->registered, na->nc);
|
||||
replacements["LAST_USED"] = Anope::strftime(ci->last_used, na->nc);
|
||||
replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname);
|
||||
replacements["ESCAPED_CHANNEL"] = HTTP::URLEncode(chname);
|
||||
|
||||
if (!ci->last_topic.empty())
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ void BuildChanList(NickAlias *na, TemplateFileServer::Replacements &replacements
|
||||
continue;
|
||||
|
||||
replacements["CHANNEL_NAMES"] = ci->name;
|
||||
replacements["ESCAPED_CHANNEL_NAMES"] = HTTPUtils::URLEncode(ci->name);
|
||||
replacements["ESCAPED_CHANNEL_NAMES"] = HTTP::URLEncode(ci->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "../webcpanel.h"
|
||||
|
||||
bool WebCPanel::Confirm::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply)
|
||||
bool WebCPanel::Confirm::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply)
|
||||
{
|
||||
TemplateFileServer::Replacements replacements;
|
||||
const Anope::string &user = message.post_data["username"], &pass = message.post_data["password"], &email = message.post_data["email"];
|
||||
|
||||
@@ -18,7 +18,7 @@ class Confirm final
|
||||
public:
|
||||
Confirm(const Anope::string &u) : WebPanelPage(u) { }
|
||||
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -17,5 +17,5 @@ class WebCPanel::HostServ::Request final
|
||||
{
|
||||
public:
|
||||
Request(const Anope::string &cat, const Anope::string &u);
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
};
|
||||
|
||||
@@ -11,12 +11,12 @@ WebCPanel::HostServ::Request::Request(const Anope::string &cat, const Anope::str
|
||||
{
|
||||
}
|
||||
|
||||
bool WebCPanel::HostServ::Request::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
bool WebCPanel::HostServ::Request::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
{
|
||||
if (message.post_data.count("req") > 0)
|
||||
{
|
||||
std::vector<Anope::string> params;
|
||||
params.push_back(HTTPUtils::URLDecode(message.post_data["req"]));
|
||||
params.push_back(HTTP::URLDecode(message.post_data["req"]));
|
||||
|
||||
WebPanel::RunCommand(client, na->nc->display, na->nc, "HostServ", "hostserv/request", params, replacements, "CMDR");
|
||||
}
|
||||
|
||||
@@ -10,15 +10,15 @@
|
||||
class WebpanelRequest final
|
||||
: public IdentifyRequest
|
||||
{
|
||||
HTTPReply reply;
|
||||
HTTPMessage message;
|
||||
Reference<HTTPProvider> server;
|
||||
HTTP::Reply reply;
|
||||
HTTP::Message message;
|
||||
Reference<HTTP::Provider> server;
|
||||
Anope::string page_name;
|
||||
Reference<HTTPClient> client;
|
||||
Reference<HTTP::Client> client;
|
||||
TemplateFileServer::Replacements replacements;
|
||||
|
||||
public:
|
||||
WebpanelRequest(Module *o, HTTPReply &r, HTTPMessage &m, HTTPProvider *s, const Anope::string &p_n, HTTPClient *c, TemplateFileServer::Replacements &re, const Anope::string &user, const Anope::string &pass)
|
||||
WebpanelRequest(Module *o, HTTP::Reply &r, HTTP::Message &m, HTTP::Provider *s, const Anope::string &p_n, HTTP::Client *c, TemplateFileServer::Replacements &re, const Anope::string &user, const Anope::string &pass)
|
||||
: IdentifyRequest(o, user, pass, c->GetIP())
|
||||
, reply(r)
|
||||
, message(m)
|
||||
@@ -69,20 +69,20 @@ public:
|
||||
na->nc->Extend<time_t>("webcpanel_last_login", Anope::CurTime);
|
||||
|
||||
{
|
||||
HTTPReply::cookie c;
|
||||
HTTP::Reply::cookie c;
|
||||
c.emplace_back("account", na->nick);
|
||||
c.emplace_back("Path", "/");
|
||||
reply.cookies.push_back(c);
|
||||
}
|
||||
|
||||
{
|
||||
HTTPReply::cookie c;
|
||||
HTTP::Reply::cookie c;
|
||||
c.emplace_back("id", id);
|
||||
c.emplace_back("Path", "/");
|
||||
reply.cookies.push_back(c);
|
||||
}
|
||||
|
||||
reply.error = HTTP_FOUND;
|
||||
reply.error = HTTP::FOUND;
|
||||
reply.headers["Location"] = Anope::string("http") + (server->IsSSL() ? "s" : "") + "://" + message.headers["Host"] + "/nickserv/info";
|
||||
|
||||
client->SendReply(&reply);
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
bool WebCPanel::Index::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply)
|
||||
bool WebCPanel::Index::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply)
|
||||
{
|
||||
TemplateFileServer::Replacements replacements;
|
||||
const Anope::string &user = message.post_data["username"], &pass = message.post_data["password"];
|
||||
|
||||
@@ -23,7 +23,7 @@ class Index final
|
||||
public:
|
||||
Index(const Anope::string &u) : WebPanelPage(u) { }
|
||||
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ WebCPanel::Logout::Logout(const Anope::string &u) : WebPanelProtectedPage("", u)
|
||||
{
|
||||
}
|
||||
|
||||
bool WebCPanel::Logout::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
bool WebCPanel::Logout::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
{
|
||||
na->Shrink<Anope::string>("webcpanel_id");
|
||||
na->Shrink<Anope::string>("webcpanel_ip");
|
||||
|
||||
reply.error = HTTP_FOUND;
|
||||
reply.error = HTTP::FOUND;
|
||||
reply.headers["Location"] = Anope::string("http") + (server->IsSSL() ? "s" : "") + "://" + message.headers["Host"] + "/";
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class Logout final
|
||||
public:
|
||||
Logout(const Anope::string &u);
|
||||
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ WebCPanel::MemoServ::Memos::Memos(const Anope::string &cat, const Anope::string
|
||||
{
|
||||
}
|
||||
|
||||
bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
bool WebCPanel::MemoServ::Memos::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
{
|
||||
const Anope::string &chname = message.get_data["channel"];
|
||||
ChannelInfo *ci;
|
||||
@@ -25,7 +25,7 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st
|
||||
if (ci->AccessFor(na->nc).HasPriv("MEMO"))
|
||||
{
|
||||
replacements["CHANNEL_NAMES"] = ci->name;
|
||||
replacements["ESCAPED_CHANNEL_NAMES"] = HTTPUtils::URLEncode(ci->name);
|
||||
replacements["ESCAPED_CHANNEL_NAMES"] = HTTP::URLEncode(ci->name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st
|
||||
mi = &ci->memos;
|
||||
|
||||
replacements["CHANNEL_NAME"] = ci->name;
|
||||
replacements["ESCAPED_CHANNEL_NAME"] = HTTPUtils::URLEncode(ci->name);
|
||||
replacements["ESCAPED_CHANNEL_NAME"] = HTTP::URLEncode(ci->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -54,8 +54,8 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st
|
||||
if (message.post_data.count("receiver") > 0 && message.post_data.count("message") > 0)
|
||||
{
|
||||
std::vector<Anope::string> params;
|
||||
params.push_back(HTTPUtils::URLDecode(message.post_data["receiver"]));
|
||||
params.push_back(HTTPUtils::URLDecode(message.post_data["message"]));
|
||||
params.push_back(HTTP::URLDecode(message.post_data["receiver"]));
|
||||
params.push_back(HTTP::URLDecode(message.post_data["message"]));
|
||||
|
||||
WebPanel::RunCommand(client, na->nc->display, na->nc, "MemoServ", "memoserv/send", params, replacements, "CMDR");
|
||||
}
|
||||
|
||||
@@ -17,5 +17,5 @@ class WebCPanel::MemoServ::Memos final
|
||||
{
|
||||
public:
|
||||
Memos(const Anope::string &cat, const Anope::string &u);
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ WebCPanel::NickServ::Alist::Alist(const Anope::string &cat, const Anope::string
|
||||
{
|
||||
}
|
||||
|
||||
bool WebCPanel::NickServ::Alist::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
bool WebCPanel::NickServ::Alist::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
{
|
||||
std::deque<ChannelInfo *> queue;
|
||||
na->nc->GetChannelReferences(queue);
|
||||
|
||||
@@ -12,7 +12,7 @@ WebCPanel::NickServ::Cert::Cert(const Anope::string &cat, const Anope::string &u
|
||||
{
|
||||
}
|
||||
|
||||
bool WebCPanel::NickServ::Cert::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
bool WebCPanel::NickServ::Cert::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
{
|
||||
if (message.post_data.count("certfp") > 0)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ WebCPanel::NickServ::Confirm::Confirm(const Anope::string &cat, const Anope::str
|
||||
{
|
||||
}
|
||||
|
||||
bool WebCPanel::NickServ::Confirm::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
bool WebCPanel::NickServ::Confirm::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
{
|
||||
|
||||
std::vector<Anope::string> params;
|
||||
|
||||
@@ -11,7 +11,7 @@ WebCPanel::NickServ::Info::Info(const Anope::string &cat, const Anope::string &u
|
||||
{
|
||||
}
|
||||
|
||||
bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
bool WebCPanel::NickServ::Info::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
{
|
||||
if (!message.post_data.empty())
|
||||
{
|
||||
@@ -31,7 +31,7 @@ bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::str
|
||||
if (message.post_data.count("greet") > 0)
|
||||
{
|
||||
Anope::string *greet = na->nc->GetExt<Anope::string>("greet");
|
||||
const Anope::string &post_greet = HTTPUtils::URLDecode(message.post_data["greet"].replace_all_cs("+", " "));
|
||||
const Anope::string &post_greet = HTTP::URLDecode(message.post_data["greet"].replace_all_cs("+", " "));
|
||||
|
||||
if (post_greet.empty())
|
||||
na->nc->Shrink<Anope::string>("greet");
|
||||
|
||||
@@ -20,7 +20,7 @@ class WebCPanel::NickServ::Alist final
|
||||
{
|
||||
public:
|
||||
Alist(const Anope::string &cat, const Anope::string &u);
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
};
|
||||
|
||||
class WebCPanel::NickServ::Cert final
|
||||
@@ -28,7 +28,7 @@ class WebCPanel::NickServ::Cert final
|
||||
{
|
||||
public:
|
||||
Cert(const Anope::string &cat, const Anope::string &u);
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
};
|
||||
|
||||
class WebCPanel::NickServ::Confirm final
|
||||
@@ -36,7 +36,7 @@ class WebCPanel::NickServ::Confirm final
|
||||
{
|
||||
public:
|
||||
Confirm(const Anope::string &cat, const Anope::string &u);
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
};
|
||||
|
||||
class WebCPanel::NickServ::Info final
|
||||
@@ -44,5 +44,5 @@ class WebCPanel::NickServ::Info final
|
||||
{
|
||||
public:
|
||||
Info(const Anope::string &cat, const Anope::string &u);
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ WebCPanel::OperServ::Akill::Akill(const Anope::string &cat, const Anope::string
|
||||
{
|
||||
}
|
||||
|
||||
bool WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
bool WebCPanel::OperServ::Akill::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
|
||||
{
|
||||
|
||||
static ServiceReference<XLineManager> akills("XLineManager","xlinemanager/sgline");
|
||||
@@ -30,9 +30,9 @@ bool WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::st
|
||||
std::vector<Anope::string> params;
|
||||
std::stringstream cmdstr;
|
||||
params.emplace_back("ADD");
|
||||
cmdstr << "+" << HTTPUtils::URLDecode(message.post_data["expiry"]);
|
||||
cmdstr << " " << HTTPUtils::URLDecode(message.post_data["mask"]);
|
||||
cmdstr << " " << HTTPUtils::URLDecode(message.post_data["reason"]);
|
||||
cmdstr << "+" << HTTP::URLDecode(message.post_data["expiry"]);
|
||||
cmdstr << " " << HTTP::URLDecode(message.post_data["mask"]);
|
||||
cmdstr << " " << HTTP::URLDecode(message.post_data["reason"]);
|
||||
params.emplace_back(cmdstr.str());
|
||||
WebPanel::RunCommand(client, na->nc->display, na->nc, "OperServ", "operserv/akill", params, replacements);
|
||||
}
|
||||
@@ -41,7 +41,7 @@ bool WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::st
|
||||
{
|
||||
std::vector<Anope::string> params;
|
||||
params.emplace_back("DEL");
|
||||
params.push_back(HTTPUtils::URLDecode(message.get_data["number"]));
|
||||
params.push_back(HTTP::URLDecode(message.get_data["number"]));
|
||||
WebPanel::RunCommand(client, na->nc->display, na->nc, "OperServ", "operserv/akill", params, replacements);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,5 +17,5 @@ class WebCPanel::OperServ::Akill final
|
||||
{
|
||||
public:
|
||||
Akill(const Anope::string &cat, const Anope::string &u);
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, NickAlias *, TemplateFileServer::Replacements &) override;
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "../webcpanel.h"
|
||||
|
||||
bool WebCPanel::Register::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply)
|
||||
bool WebCPanel::Register::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply)
|
||||
{
|
||||
TemplateFileServer::Replacements replacements;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class Register final
|
||||
public:
|
||||
Register(const Anope::string &u) : WebPanelPage(u) { }
|
||||
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -13,18 +13,18 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
StaticFileServer::StaticFileServer(const Anope::string &f_n, const Anope::string &u, const Anope::string &c_t) : HTTPPage(u, c_t), file_name(f_n)
|
||||
StaticFileServer::StaticFileServer(const Anope::string &f_n, const Anope::string &u, const Anope::string &c_t) : HTTP::Page(u, c_t), file_name(f_n)
|
||||
{
|
||||
}
|
||||
|
||||
bool StaticFileServer::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply)
|
||||
bool StaticFileServer::OnRequest(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply)
|
||||
{
|
||||
int fd = open((template_base + "/" + this->file_name).c_str(), O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
Log(LOG_NORMAL, "httpd") << "Error serving file " << page_name << " (" << (template_base + "/" + this->file_name) << "): " << strerror(errno);
|
||||
|
||||
client->SendError(HTTP_PAGE_NOT_FOUND, "Page not found");
|
||||
client->SendError(HTTP::PAGE_NOT_FOUND, "Page not found");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
|
||||
/* A basic file server. Used for serving static content on disk. */
|
||||
class StaticFileServer final
|
||||
: public HTTPPage
|
||||
: public HTTP::Page
|
||||
{
|
||||
Anope::string file_name;
|
||||
public:
|
||||
StaticFileServer(const Anope::string &f_n, const Anope::string &u, const Anope::string &c_t);
|
||||
|
||||
bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) override;
|
||||
bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &) override;
|
||||
};
|
||||
|
||||
@@ -86,14 +86,14 @@ TemplateFileServer::TemplateFileServer(const Anope::string &f_n) : file_name(f_n
|
||||
{
|
||||
}
|
||||
|
||||
void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, Replacements &r)
|
||||
void TemplateFileServer::Serve(HTTP::Provider *server, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply, Replacements &r)
|
||||
{
|
||||
int fd = open((template_base + "/" + this->file_name).c_str(), O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
Log(LOG_NORMAL, "httpd") << "Error serving file " << page_name << " (" << (template_base + "/" + this->file_name) << "): " << strerror(errno);
|
||||
|
||||
client->SendError(HTTP_PAGE_NOT_FOUND, "Page not found");
|
||||
client->SendError(HTTP::PAGE_NOT_FOUND, "Page not found");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n
|
||||
Anope::string replacement = FindReplacement(r, content.substr(0, f - 1));
|
||||
|
||||
// htmlescape all text replaced onto the page
|
||||
replacement = HTTPUtils::Escape(replacement);
|
||||
replacement = HTTP::Escape(replacement);
|
||||
|
||||
finished += replacement;
|
||||
}
|
||||
|
||||
@@ -25,5 +25,5 @@ public:
|
||||
|
||||
TemplateFileServer(const Anope::string &f_n);
|
||||
|
||||
void Serve(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, Replacements &);
|
||||
void Serve(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, Replacements &);
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ Anope::string provider_name, template_base, page_title;
|
||||
class ModuleWebCPanel final
|
||||
: public Module
|
||||
{
|
||||
ServiceReference<HTTPProvider> provider;
|
||||
ServiceReference<HTTP::Provider> provider;
|
||||
Panel panel;
|
||||
PrimitiveExtensibleItem<Anope::string> id, ip;
|
||||
PrimitiveExtensibleItem<time_t> last_login;
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
template_base = Anope::ExpandData(block.Get<const Anope::string>("template_dir", "webcpanel/templates/default"));
|
||||
page_title = block.Get<const Anope::string>("title", "Anope IRC Services");
|
||||
|
||||
provider = ServiceReference<HTTPProvider>("HTTPProvider", provider_name);
|
||||
provider = ServiceReference<HTTP::Provider>(HTTP_PROVIDER, provider_name);
|
||||
if (!provider)
|
||||
throw ModuleException("Unable to find HTTPD provider. Is httpd loaded?");
|
||||
|
||||
@@ -233,7 +233,7 @@ public:
|
||||
|
||||
namespace WebPanel
|
||||
{
|
||||
void RunCommand(HTTPClient *client, const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key)
|
||||
void RunCommand(HTTP::Client *client, const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key)
|
||||
{
|
||||
ServiceReference<Command> cmd("Command", c);
|
||||
if (!cmd)
|
||||
@@ -277,7 +277,7 @@ namespace WebPanel
|
||||
cmd->Run(source, "", info, params);
|
||||
}
|
||||
|
||||
void RunCommandWithName(HTTPClient *client, NickCore *nc, const Anope::string &service, const Anope::string &c, const Anope::string &cmdname, std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key)
|
||||
void RunCommandWithName(HTTP::Client *client, NickCore *nc, const Anope::string &service, const Anope::string &c, const Anope::string &cmdname, std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key)
|
||||
{
|
||||
ServiceReference<Command> cmd("Command", c);
|
||||
if (!cmd)
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
|
||||
std::vector<Section> sections;
|
||||
|
||||
NickAlias *GetNickFromSession(HTTPClient *client, HTTPMessage &msg)
|
||||
NickAlias *GetNickFromSession(HTTP::Client *client, HTTP::Message &msg)
|
||||
{
|
||||
if (!client)
|
||||
return NULL;
|
||||
@@ -66,14 +66,14 @@ public:
|
||||
};
|
||||
|
||||
class WebPanelPage
|
||||
: public HTTPPage
|
||||
: public HTTP::Page
|
||||
{
|
||||
public:
|
||||
WebPanelPage(const Anope::string &u, const Anope::string &ct = "text/html") : HTTPPage(u, ct)
|
||||
WebPanelPage(const Anope::string &u, const Anope::string &ct = "text/html") : HTTP::Page(u, ct)
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) = 0;
|
||||
virtual bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &) = 0;
|
||||
};
|
||||
|
||||
class WebPanelProtectedPage
|
||||
@@ -86,14 +86,14 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
bool OnRequest(HTTPProvider *provider, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) override final
|
||||
bool OnRequest(HTTP::Provider *provider, const Anope::string &page_name, HTTP::Client *client, HTTP::Message &message, HTTP::Reply &reply) override final
|
||||
{
|
||||
ServiceReference<Panel> panel("Panel", "webcpanel");
|
||||
NickAlias *na;
|
||||
|
||||
if (!panel || !(na = panel->GetNickFromSession(client, message)))
|
||||
{
|
||||
reply.error = HTTP_FOUND;
|
||||
reply.error = HTTP::FOUND;
|
||||
reply.headers["Location"] = Anope::string("http") + (provider->IsSSL() ? "s" : "") + "://" + message.headers["Host"] + "/";
|
||||
return true; // Access denied
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public:
|
||||
for (const auto &[key, value] : message.get_data)
|
||||
{
|
||||
if (this->GetData().count(key) > 0)
|
||||
get += "&" + key + "=" + HTTPUtils::URLEncode(value);
|
||||
get += "&" + key + "=" + HTTP::URLEncode(value);
|
||||
}
|
||||
if (get.empty() == false)
|
||||
get = "?" + get.substr(1);
|
||||
@@ -140,7 +140,7 @@ public:
|
||||
return this->OnRequest(provider, page_name, client, message, reply, na, replacements);
|
||||
}
|
||||
|
||||
virtual bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &, NickAlias *, TemplateFileServer::Replacements &) = 0;
|
||||
virtual bool OnRequest(HTTP::Provider *, const Anope::string &, HTTP::Client *, HTTP::Message &, HTTP::Reply &, NickAlias *, TemplateFileServer::Replacements &) = 0;
|
||||
|
||||
/* What get data should be appended to links in the navbar */
|
||||
virtual std::set<Anope::string> GetData() { return std::set<Anope::string>(); }
|
||||
@@ -158,9 +158,9 @@ namespace WebPanel
|
||||
* @param r Replacements, reply from command goes back here into key
|
||||
* @param key The key to put the replies into r
|
||||
*/
|
||||
extern void RunCommand(HTTPClient *client, const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES");
|
||||
extern void RunCommand(HTTP::Client *client, const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES");
|
||||
|
||||
extern void RunCommandWithName(HTTPClient *client, NickCore *nc, const Anope::string &service, const Anope::string &c, const Anope::string &cmdname, std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES");
|
||||
extern void RunCommandWithName(HTTP::Client *client, NickCore *nc, const Anope::string &service, const Anope::string &c, const Anope::string &cmdname, std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r, const Anope::string &key = "MESSAGES");
|
||||
}
|
||||
|
||||
#include "pages/index.h"
|
||||
|
||||
Reference in New Issue
Block a user