mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Hyperiond refactoring + preparation for ip restriction settings (#12)
* make hyperion to singelton. remove arguments for config and hyperion - both are gettable via Hyperion::getInstance * refactor hyperiond * remove qt4 comapt make zeroconf mandatory refactor hyperiond * xbmcchecker is now a singleton * cleanup in hyperiond zeroconf switchable between static and shared linking * fix xbmcchecker * extensive refactoring of hyperiond webserver: make client ip information availabel in request object - preparation for ip filters proto/json server, use hyperion::getInstance instead of hyperion argument * move creation of hyperion core into hyperionDeamon class cleanup
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <QByteArray>
|
||||
|
||||
#include "CgiHandler.h"
|
||||
#include "QtHttpHeader.h"
|
||||
|
||||
CgiHandler::CgiHandler (Hyperion * hyperion, QObject * parent)
|
||||
: QObject(parent)
|
||||
@@ -16,10 +17,15 @@ CgiHandler::~CgiHandler()
|
||||
{
|
||||
}
|
||||
|
||||
void CgiHandler::exec(const QStringList & args, QtHttpReply * reply)
|
||||
void CgiHandler::exec(const QStringList & args, QtHttpRequest * request, QtHttpReply * reply)
|
||||
{
|
||||
try
|
||||
{
|
||||
// QByteArray header = reply->getHeader(QtHttpHeader::Host);
|
||||
// QtHttpRequest::ClientInfo info = request->getClientInfo();
|
||||
// qDebug() << info.clientAddress.toString();
|
||||
// qDebug() << info.serverAddress.toString();
|
||||
|
||||
cmd_cfg_jsonserver(args,reply);
|
||||
cmd_cfg_hyperion(args,reply);
|
||||
throw 1;
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include <hyperion/Hyperion.h>
|
||||
|
||||
#include "QtHttpReply.h"
|
||||
#include "QtHttpRequest.h"
|
||||
|
||||
class CgiHandler : public QObject {
|
||||
Q_OBJECT
|
||||
@@ -17,7 +18,7 @@ public:
|
||||
CgiHandler (Hyperion * hyperion, QObject * parent = NULL);
|
||||
virtual ~CgiHandler (void);
|
||||
|
||||
void exec(const QStringList & args, QtHttpReply * reply);
|
||||
void exec(const QStringList & args,QtHttpRequest * request, QtHttpReply * reply);
|
||||
|
||||
// cgi commands
|
||||
void cmd_cfg_jsonserver(const QStringList & args, QtHttpReply * reply);
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include <QStringBuilder>
|
||||
#include <QStringList>
|
||||
#include <QDateTime>
|
||||
#include <QHostAddress>
|
||||
|
||||
const QByteArray & QtHttpClientWrapper::CRLF = QByteArrayLiteral ("\r\n");
|
||||
|
||||
@@ -54,6 +55,7 @@ void QtHttpClientWrapper::onClientDataReceived (void) {
|
||||
// << "url :" << url
|
||||
// << "version :" << version;
|
||||
m_currentRequest = new QtHttpRequest (m_serverHandle);
|
||||
m_currentRequest->setClientInfo(m_sockClient->localAddress(), m_sockClient->peerAddress());
|
||||
m_currentRequest->setUrl (QUrl (url));
|
||||
m_currentRequest->setCommand (command);
|
||||
m_parsingStatus = AwaitingHeaders;
|
||||
|
@@ -23,6 +23,10 @@ QString QtHttpRequest::getCommand (void) const {
|
||||
return m_command;
|
||||
}
|
||||
|
||||
QtHttpRequest::ClientInfo QtHttpRequest::getClientInfo (void) const {
|
||||
return m_clientInfo;
|
||||
}
|
||||
|
||||
int QtHttpRequest::getRawDataSize (void) const {
|
||||
return m_data.size ();
|
||||
}
|
||||
@@ -48,6 +52,11 @@ void QtHttpRequest::setCommand (const QString & command) {
|
||||
m_command = command;
|
||||
}
|
||||
|
||||
void QtHttpRequest::setClientInfo (const QHostAddress & server, const QHostAddress & client) {
|
||||
m_clientInfo.serverAddress = server;
|
||||
m_clientInfo.clientAddress = client;
|
||||
}
|
||||
|
||||
void QtHttpRequest::addHeader (const QByteArray & header, const QByteArray & value) {
|
||||
QByteArray key = header.trimmed ();
|
||||
if (!key.isEmpty ()) {
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include <QByteArray>
|
||||
#include <QHash>
|
||||
#include <QUrl>
|
||||
#include <QHostAddress>
|
||||
|
||||
class QtHttpServer;
|
||||
|
||||
@@ -15,17 +16,24 @@ class QtHttpRequest : public QObject {
|
||||
public:
|
||||
explicit QtHttpRequest (QtHttpServer * parent);
|
||||
|
||||
int getRawDataSize (void) const;
|
||||
struct ClientInfo {
|
||||
QHostAddress serverAddress;
|
||||
QHostAddress clientAddress;
|
||||
};
|
||||
|
||||
int getRawDataSize (void) const;
|
||||
QUrl getUrl (void) const;
|
||||
QString getCommand (void) const;
|
||||
QByteArray getRawData (void) const;
|
||||
QList<QByteArray> getHeadersList (void) const;
|
||||
ClientInfo getClientInfo (void) const;
|
||||
|
||||
QByteArray getHeader (const QByteArray & header) const;
|
||||
|
||||
public slots:
|
||||
void setUrl (const QUrl & url);
|
||||
void setCommand (const QString & command);
|
||||
void setClientInfo (const QHostAddress & server, const QHostAddress & client);
|
||||
void addHeader (const QByteArray & header, const QByteArray & value);
|
||||
void appendRawData (const QByteArray & data);
|
||||
|
||||
@@ -35,6 +43,7 @@ private:
|
||||
QByteArray m_data;
|
||||
QtHttpServer * m_serverHandle;
|
||||
QHash<QByteArray, QByteArray> m_headersHash;
|
||||
ClientInfo m_clientInfo;
|
||||
};
|
||||
|
||||
#endif // QTHTTPREQUEST_H
|
||||
|
@@ -66,7 +66,7 @@ void StaticFileServing::onRequestNeedsReply (QtHttpRequest * request, QtHttpRepl
|
||||
uri_parts.removeAt(0);
|
||||
try
|
||||
{
|
||||
_cgi.exec(uri_parts, reply);
|
||||
_cgi.exec(uri_parts, request, reply);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
@@ -16,7 +16,7 @@ class StaticFileServing : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit StaticFileServing (Hyperion *hyperion, QString baseUrl, quint16 port, QObject * parent = NULL);
|
||||
explicit StaticFileServing (Hyperion *hyperion, QString baseUrl, quint16 port, QObject * parent = nullptr);
|
||||
virtual ~StaticFileServing (void);
|
||||
|
||||
public slots:
|
||||
|
Reference in New Issue
Block a user