mirror of
https://github.com/NohamR/RMHook-Win.git
synced 2026-05-26 04:17:10 +00:00
Add Qt libs and headers
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QDEFAULTMASKGENERATOR_P_H
|
||||
#define QDEFAULTMASKGENERATOR_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtWebSockets/qmaskgenerator.h>
|
||||
#include <QtCore/private/qglobal_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QObject;
|
||||
|
||||
class Q_AUTOTEST_EXPORT QDefaultMaskGenerator : public QMaskGenerator
|
||||
{
|
||||
Q_DISABLE_COPY(QDefaultMaskGenerator)
|
||||
|
||||
public:
|
||||
explicit QDefaultMaskGenerator(QObject *parent = nullptr);
|
||||
~QDefaultMaskGenerator() override;
|
||||
|
||||
bool seed() noexcept override;
|
||||
quint32 nextMask() noexcept override;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDEFAULTMASKGENERATOR_P_H
|
||||
@@ -0,0 +1,242 @@
|
||||
// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QWEBSOCKET_P_H
|
||||
#define QWEBSOCKET_P_H
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtNetwork/QTcpSocket>
|
||||
#include <QtNetwork/QHostAddress>
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#include <QtNetwork/QNetworkProxy>
|
||||
#endif
|
||||
#ifndef QT_NO_SSL
|
||||
#include <QtNetwork/QSslConfiguration>
|
||||
#include <QtNetwork/QSslError>
|
||||
#include <QtNetwork/QSslSocket>
|
||||
#endif
|
||||
#include <QtCore/QElapsedTimer>
|
||||
#include <private/qobject_p.h>
|
||||
|
||||
#include "qwebsocket.h"
|
||||
#include "qwebsockethandshakeoptions.h"
|
||||
#include "qwebsocketprotocol.h"
|
||||
#include "qwebsocketdataprocessor_p.h"
|
||||
#include "qdefaultmaskgenerator_p.h"
|
||||
|
||||
#ifdef Q_OS_WASM
|
||||
# include <emscripten/websocket.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWebSocketHandshakeRequest;
|
||||
class QWebSocketHandshakeResponse;
|
||||
class QTcpSocket;
|
||||
class QWebSocket;
|
||||
class QMaskGenerator;
|
||||
|
||||
struct QWebSocketConfiguration
|
||||
{
|
||||
Q_DISABLE_COPY(QWebSocketConfiguration)
|
||||
|
||||
public:
|
||||
QWebSocketConfiguration();
|
||||
|
||||
public:
|
||||
#ifndef QT_NO_SSL
|
||||
QSslConfiguration m_sslConfiguration;
|
||||
QList<QSslError> m_ignoredSslErrors;
|
||||
bool m_ignoreSslErrors;
|
||||
#endif
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QNetworkProxy m_proxy;
|
||||
#endif
|
||||
QTcpSocket *m_pSocket;
|
||||
};
|
||||
|
||||
class QWebSocketPrivate : public QObjectPrivate
|
||||
{
|
||||
Q_DISABLE_COPY(QWebSocketPrivate)
|
||||
|
||||
public:
|
||||
Q_DECLARE_PUBLIC(QWebSocket)
|
||||
explicit QWebSocketPrivate(const QString &origin,
|
||||
QWebSocketProtocol::Version version);
|
||||
~QWebSocketPrivate() override;
|
||||
|
||||
// both constants are taken from the default settings of Apache
|
||||
// see: http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfieldsize and
|
||||
// http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfields
|
||||
static constexpr int MAX_HEADERLINE_LENGTH = 8 * 1024; // maximum length of a http request header line
|
||||
static constexpr int MAX_HEADERLINES = 100; // maximum number of http request header lines
|
||||
|
||||
void init();
|
||||
void abort();
|
||||
QAbstractSocket::SocketError error() const;
|
||||
QString errorString() const;
|
||||
bool flush();
|
||||
bool isValid() const;
|
||||
QHostAddress localAddress() const;
|
||||
quint16 localPort() const;
|
||||
QAbstractSocket::PauseModes pauseMode() const;
|
||||
QHostAddress peerAddress() const;
|
||||
QString peerName() const;
|
||||
quint16 peerPort() const;
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QNetworkProxy proxy() const;
|
||||
void setProxy(const QNetworkProxy &networkProxy);
|
||||
#endif
|
||||
void setMaskGenerator(const QMaskGenerator *maskGenerator);
|
||||
const QMaskGenerator *maskGenerator() const;
|
||||
qint64 readBufferSize() const;
|
||||
void resume();
|
||||
void setPauseMode(QAbstractSocket::PauseModes pauseMode);
|
||||
void setReadBufferSize(qint64 size);
|
||||
QAbstractSocket::SocketState state() const;
|
||||
|
||||
QWebSocketProtocol::Version version() const;
|
||||
QString resourceName() const;
|
||||
QNetworkRequest request() const;
|
||||
QString origin() const;
|
||||
QWebSocketHandshakeOptions handshakeOptions() const;
|
||||
QString protocol() const;
|
||||
QString extension() const;
|
||||
QWebSocketProtocol::CloseCode closeCode() const;
|
||||
QString closeReason() const;
|
||||
|
||||
qint64 sendTextMessage(const QString &message);
|
||||
qint64 sendBinaryMessage(const QByteArray &data);
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
void ignoreSslErrors(const QList<QSslError> &errors);
|
||||
void ignoreSslErrors();
|
||||
void continueInterruptedHandshake();
|
||||
void setSslConfiguration(const QSslConfiguration &sslConfiguration);
|
||||
QSslConfiguration sslConfiguration() const;
|
||||
void _q_updateSslConfiguration();
|
||||
#endif
|
||||
|
||||
void closeGoingAway();
|
||||
void close(QWebSocketProtocol::CloseCode closeCode, QString reason);
|
||||
void open(const QNetworkRequest &request, const QWebSocketHandshakeOptions &options, bool mask);
|
||||
void ping(const QByteArray &payload);
|
||||
void setSocketState(QAbstractSocket::SocketState state);
|
||||
|
||||
void setMaxAllowedIncomingFrameSize(quint64 maxAllowedIncomingFrameSize);
|
||||
quint64 maxAllowedIncomingFrameSize() const;
|
||||
void setMaxAllowedIncomingMessageSize(quint64 maxAllowedIncomingMessageSize);
|
||||
quint64 maxAllowedIncomingMessageSize() const;
|
||||
static quint64 maxIncomingMessageSize();
|
||||
static quint64 maxIncomingFrameSize();
|
||||
|
||||
void setOutgoingFrameSize(quint64 outgoingFrameSize);
|
||||
quint64 outgoingFrameSize() const;
|
||||
static quint64 maxOutgoingFrameSize();
|
||||
#ifdef Q_OS_WASM
|
||||
void setSocketClosed(const EmscriptenWebSocketCloseEvent *emCloseEvent);
|
||||
QString closeCodeToString(QWebSocketProtocol::CloseCode code);
|
||||
#endif
|
||||
private:
|
||||
QWebSocketPrivate(QTcpSocket *pTcpSocket, QWebSocketProtocol::Version version);
|
||||
void setVersion(QWebSocketProtocol::Version version);
|
||||
void setResourceName(const QString &resourceName);
|
||||
void setRequest(const QNetworkRequest &request, const QWebSocketHandshakeOptions &options = {});
|
||||
void setOrigin(const QString &origin);
|
||||
void setProtocol(const QString &protocol);
|
||||
void setExtension(const QString &extension);
|
||||
void enableMasking(bool enable);
|
||||
void setErrorString(const QString &errorString);
|
||||
|
||||
QStringList requestedSubProtocols() const;
|
||||
|
||||
void socketDestroyed(QObject *socket);
|
||||
|
||||
void processData();
|
||||
void processPing(const QByteArray &data);
|
||||
void processPong(const QByteArray &data);
|
||||
void processClose(QWebSocketProtocol::CloseCode closeCode, QString closeReason);
|
||||
void processHandshake(QTcpSocket *pSocket);
|
||||
void processStateChanged(QAbstractSocket::SocketState socketState);
|
||||
|
||||
Q_REQUIRED_RESULT qint64 doWriteFrames(const QByteArray &data, bool isBinary);
|
||||
|
||||
void makeConnections(QTcpSocket *pTcpSocket);
|
||||
void releaseConnections(const QTcpSocket *pTcpSocket);
|
||||
|
||||
QByteArray getFrameHeader(QWebSocketProtocol::OpCode opCode, quint64 payloadLength,
|
||||
quint32 maskingKey, bool lastFrame);
|
||||
QString calculateAcceptKey(const QByteArray &key) const;
|
||||
QString createHandShakeRequest(QString resourceName,
|
||||
QString host,
|
||||
QString origin,
|
||||
QString extensions,
|
||||
const QStringList &options,
|
||||
QByteArray key,
|
||||
const QList<QPair<QString, QString> > &headers);
|
||||
|
||||
Q_REQUIRED_RESULT static QWebSocket *
|
||||
upgradeFrom(QTcpSocket *tcpSocket,
|
||||
const QWebSocketHandshakeRequest &request,
|
||||
const QWebSocketHandshakeResponse &response,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
quint32 generateMaskingKey() const;
|
||||
QByteArray generateKey() const;
|
||||
Q_REQUIRED_RESULT qint64 writeFrames(const QList<QByteArray> &frames);
|
||||
Q_REQUIRED_RESULT qint64 writeFrame(const QByteArray &frame);
|
||||
void emitErrorOccurred(QAbstractSocket::SocketError error);
|
||||
|
||||
QTcpSocket *m_pSocket;
|
||||
QString m_errorString;
|
||||
QWebSocketProtocol::Version m_version;
|
||||
QUrl m_resource;
|
||||
QString m_resourceName;
|
||||
QNetworkRequest m_request;
|
||||
QWebSocketHandshakeOptions m_options;
|
||||
QString m_origin;
|
||||
QString m_protocol;
|
||||
QString m_extension;
|
||||
QAbstractSocket::SocketState m_socketState;
|
||||
QAbstractSocket::PauseModes m_pauseMode;
|
||||
qint64 m_readBufferSize;
|
||||
|
||||
QByteArray m_key; //identification key used in handshake requests
|
||||
|
||||
bool m_mustMask; //a server must not mask the frames it sends
|
||||
|
||||
bool m_isClosingHandshakeSent;
|
||||
bool m_isClosingHandshakeReceived;
|
||||
QWebSocketProtocol::CloseCode m_closeCode;
|
||||
QString m_closeReason;
|
||||
|
||||
QElapsedTimer m_pingTimer;
|
||||
|
||||
QWebSocketDataProcessor *m_dataProcessor = new QWebSocketDataProcessor();
|
||||
QWebSocketConfiguration m_configuration;
|
||||
|
||||
QMaskGenerator *m_pMaskGenerator;
|
||||
QDefaultMaskGenerator m_defaultMaskGenerator;
|
||||
|
||||
quint64 m_outgoingFrameSize;
|
||||
|
||||
friend class QWebSocketServerPrivate;
|
||||
#ifdef Q_OS_WASM
|
||||
EMSCRIPTEN_WEBSOCKET_T m_socketContext = 0;
|
||||
uint16_t m_readyState = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWEBSOCKET_H
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
#ifndef QWEBSOCKETCORSAUTHENTICATOR_P_H
|
||||
#define QWEBSOCKETCORSAUTHENTICATOR_P_H
|
||||
|
||||
#include <QtCore/private/qglobal_p.h>
|
||||
#include <QtCore/QString>
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWebSocketCorsAuthenticatorPrivate
|
||||
{
|
||||
public:
|
||||
QWebSocketCorsAuthenticatorPrivate(const QString &origin, bool allowed);
|
||||
~QWebSocketCorsAuthenticatorPrivate();
|
||||
|
||||
QString m_origin;
|
||||
bool m_isAllowed;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWEBSOCKETCORSAUTHENTICATOR_P_H
|
||||
@@ -0,0 +1,95 @@
|
||||
// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QWEBSOCKETDATAPROCESSOR_P_H
|
||||
#define QWEBSOCKETDATAPROCESSOR_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringDecoder>
|
||||
#include <QtCore/QTimer>
|
||||
#include "qwebsocketframe_p.h"
|
||||
#include "qwebsocketprotocol.h"
|
||||
#include "qwebsocketprotocol_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QIODevice;
|
||||
class QWebSocketFrame;
|
||||
|
||||
const quint64 MAX_MESSAGE_SIZE_IN_BYTES = std::numeric_limits<int>::max() - 1;
|
||||
|
||||
class Q_AUTOTEST_EXPORT QWebSocketDataProcessor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(QWebSocketDataProcessor)
|
||||
|
||||
public:
|
||||
explicit QWebSocketDataProcessor(QObject *parent = nullptr);
|
||||
~QWebSocketDataProcessor() override;
|
||||
|
||||
void setMaxAllowedFrameSize(quint64 maxAllowedFrameSize);
|
||||
quint64 maxAllowedFrameSize() const;
|
||||
void setMaxAllowedMessageSize(quint64 maxAllowedMessageSize);
|
||||
quint64 maxAllowedMessageSize() const;
|
||||
static quint64 maxMessageSize();
|
||||
static quint64 maxFrameSize();
|
||||
|
||||
Q_SIGNALS:
|
||||
void pingReceived(const QByteArray &data);
|
||||
void pongReceived(const QByteArray &data);
|
||||
void closeReceived(QWebSocketProtocol::CloseCode closeCode, const QString &closeReason);
|
||||
void textFrameReceived(const QString &frame, bool lastFrame);
|
||||
void binaryFrameReceived(const QByteArray &frame, bool lastFrame);
|
||||
void textMessageReceived(const QString &message);
|
||||
void binaryMessageReceived(const QByteArray &message);
|
||||
void errorEncountered(QWebSocketProtocol::CloseCode code, const QString &description);
|
||||
|
||||
public Q_SLOTS:
|
||||
bool process(QIODevice *pIoDevice);
|
||||
void clear();
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
PS_READ_HEADER,
|
||||
PS_READ_PAYLOAD_LENGTH,
|
||||
PS_READ_BIG_PAYLOAD_LENGTH,
|
||||
PS_READ_MASK,
|
||||
PS_READ_PAYLOAD,
|
||||
PS_DISPATCH_RESULT
|
||||
} m_processingState;
|
||||
|
||||
bool m_isFinalFrame;
|
||||
bool m_isFragmented;
|
||||
QWebSocketProtocol::OpCode m_opCode;
|
||||
bool m_isControlFrame;
|
||||
bool m_hasMask;
|
||||
quint32 m_mask;
|
||||
QByteArray m_binaryMessage;
|
||||
QString m_textMessage;
|
||||
quint64 m_payloadLength;
|
||||
QStringDecoder m_decoder;
|
||||
QWebSocketFrame frame;
|
||||
QTimer *m_waitTimer;
|
||||
quint64 m_maxAllowedMessageSize = MAX_MESSAGE_SIZE_IN_BYTES;
|
||||
|
||||
bool processControlFrame(const QWebSocketFrame &frame);
|
||||
void timeout();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWEBSOCKETDATAPROCESSOR_P_H
|
||||
@@ -0,0 +1,101 @@
|
||||
// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QWEBSOCKETFRAME_P_H
|
||||
#define QWEBSOCKETFRAME_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <limits>
|
||||
|
||||
#include "qwebsockets_global.h"
|
||||
#include "qwebsocketprotocol.h"
|
||||
#include "qwebsocketprotocol_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QIODevice;
|
||||
|
||||
const quint64 MAX_FRAME_SIZE_IN_BYTES = std::numeric_limits<int>::max() - 1;
|
||||
|
||||
class Q_AUTOTEST_EXPORT QWebSocketFrame
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(QWebSocketFrame)
|
||||
|
||||
public:
|
||||
QWebSocketFrame() = default;
|
||||
|
||||
void setMaxAllowedFrameSize(quint64 maxAllowedFrameSize);
|
||||
quint64 maxAllowedFrameSize() const;
|
||||
static quint64 maxFrameSize();
|
||||
|
||||
QWebSocketProtocol::CloseCode closeCode() const;
|
||||
QString closeReason() const;
|
||||
bool isFinalFrame() const;
|
||||
bool isControlFrame() const;
|
||||
bool isDataFrame() const;
|
||||
bool isContinuationFrame() const;
|
||||
bool hasMask() const;
|
||||
quint32 mask() const; //returns 0 if no mask
|
||||
inline bool rsv1() const { return m_rsv1; }
|
||||
inline bool rsv2() const { return m_rsv2; }
|
||||
inline bool rsv3() const { return m_rsv3; }
|
||||
QWebSocketProtocol::OpCode opCode() const;
|
||||
QByteArray payload() const;
|
||||
|
||||
void clear();
|
||||
|
||||
bool isValid() const;
|
||||
bool isDone() const;
|
||||
|
||||
void readFrame(QIODevice *pIoDevice);
|
||||
|
||||
private:
|
||||
QString m_closeReason;
|
||||
QByteArray m_payload;
|
||||
quint64 m_length = 0;
|
||||
quint32 m_mask = 0;
|
||||
QWebSocketProtocol::CloseCode m_closeCode = QWebSocketProtocol::CloseCodeNormal;
|
||||
QWebSocketProtocol::OpCode m_opCode = QWebSocketProtocol::OpCodeReservedC;
|
||||
|
||||
enum ProcessingState
|
||||
{
|
||||
PS_READ_HEADER,
|
||||
PS_READ_PAYLOAD_LENGTH,
|
||||
PS_READ_MASK,
|
||||
PS_READ_PAYLOAD,
|
||||
PS_DISPATCH_RESULT,
|
||||
PS_WAIT_FOR_MORE_DATA
|
||||
} m_processingState = PS_READ_HEADER;
|
||||
|
||||
bool m_isFinalFrame = true;
|
||||
bool m_rsv1 = false;
|
||||
bool m_rsv2 = false;
|
||||
bool m_rsv3 = false;
|
||||
bool m_isValid = false;
|
||||
quint64 m_maxAllowedFrameSize = MAX_FRAME_SIZE_IN_BYTES;
|
||||
|
||||
ProcessingState readFrameHeader(QIODevice *pIoDevice);
|
||||
ProcessingState readFramePayloadLength(QIODevice *pIoDevice);
|
||||
ProcessingState readFrameMask(QIODevice *pIoDevice);
|
||||
ProcessingState readFramePayload(QIODevice *pIoDevice);
|
||||
|
||||
void setError(QWebSocketProtocol::CloseCode code, const QString &closeReason);
|
||||
bool checkValidity();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWEBSOCKETFRAME_P_H
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2022 Menlo Systems GmbH, author Arno Rehn <a.rehn@menlosystems.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QWEBSOCKETHANDSHAKEOPTIONS_P_H
|
||||
#define QWEBSOCKETHANDSHAKEOPTIONS_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QSharedData>
|
||||
|
||||
#include "qwebsockethandshakeoptions.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Q_AUTOTEST_EXPORT QWebSocketHandshakeOptionsPrivate : public QSharedData
|
||||
{
|
||||
public:
|
||||
inline bool operator==(const QWebSocketHandshakeOptionsPrivate &other) const
|
||||
{ return subprotocols == other.subprotocols; }
|
||||
|
||||
QStringList subprotocols;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWEBSOCKETHANDSHAKEOPTIONS_P_H
|
||||
@@ -0,0 +1,71 @@
|
||||
// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QWEBSOCKETHANDSHAKEREQUEST_P_H
|
||||
#define QWEBSOCKETHANDSHAKEREQUEST_P_H
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtNetwork/private/qhttpheaderparser_p.h>
|
||||
|
||||
#include "qwebsocketprotocol.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QTextStream;
|
||||
|
||||
class Q_AUTOTEST_EXPORT QWebSocketHandshakeRequest
|
||||
{
|
||||
Q_DISABLE_COPY(QWebSocketHandshakeRequest)
|
||||
|
||||
public:
|
||||
QWebSocketHandshakeRequest(int port, bool isSecure);
|
||||
virtual ~QWebSocketHandshakeRequest();
|
||||
|
||||
void clear();
|
||||
|
||||
int port() const;
|
||||
bool isSecure() const;
|
||||
bool isValid() const;
|
||||
QList<QPair<QByteArray, QByteArray>> headers() const;
|
||||
bool hasHeader(const QByteArray &name) const;
|
||||
QList<QWebSocketProtocol::Version> versions() const;
|
||||
QString key() const;
|
||||
QString origin() const;
|
||||
QList<QString> protocols() const;
|
||||
QList<QString> extensions() const;
|
||||
QUrl requestUrl() const;
|
||||
QString resourceName() const;
|
||||
QString host() const;
|
||||
|
||||
void readHandshake(QByteArrayView header, int maxHeaderLineLength);
|
||||
|
||||
private:
|
||||
|
||||
int m_port;
|
||||
bool m_isSecure;
|
||||
bool m_isValid;
|
||||
QHttpHeaderParser m_parser;
|
||||
QList<QWebSocketProtocol::Version> m_versions;
|
||||
QString m_key;
|
||||
QString m_origin;
|
||||
QList<QString> m_protocols;
|
||||
QList<QString> m_extensions;
|
||||
QUrl m_requestUrl;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWEBSOCKETHANDSHAKEREQUEST_P_H
|
||||
@@ -0,0 +1,80 @@
|
||||
// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QWEBSOCKETHANDSHAKERESPONSE_P_H
|
||||
#define QWEBSOCKETHANDSHAKERESPONSE_P_H
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QList>
|
||||
#include "qwebsocketprotocol.h"
|
||||
#include "private/qglobal_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWebSocketHandshakeRequest;
|
||||
class QString;
|
||||
class QTextStream;
|
||||
|
||||
class Q_AUTOTEST_EXPORT QWebSocketHandshakeResponse : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(QWebSocketHandshakeResponse)
|
||||
|
||||
public:
|
||||
QWebSocketHandshakeResponse(const QWebSocketHandshakeRequest &request,
|
||||
const QString &serverName,
|
||||
bool isOriginAllowed,
|
||||
const QList<QWebSocketProtocol::Version> &supportedVersions,
|
||||
const QList<QString> &supportedProtocols,
|
||||
const QList<QString> &supportedExtensions);
|
||||
|
||||
~QWebSocketHandshakeResponse() override;
|
||||
|
||||
bool isValid() const;
|
||||
bool canUpgrade() const;
|
||||
QString acceptedProtocol() const;
|
||||
QString acceptedExtension() const;
|
||||
QWebSocketProtocol::Version acceptedVersion() const;
|
||||
|
||||
QWebSocketProtocol::CloseCode error() const;
|
||||
QString errorString() const;
|
||||
|
||||
private:
|
||||
bool m_isValid;
|
||||
bool m_canUpgrade;
|
||||
QString m_response;
|
||||
QString m_acceptedProtocol;
|
||||
QString m_acceptedExtension;
|
||||
QWebSocketProtocol::Version m_acceptedVersion;
|
||||
QWebSocketProtocol::CloseCode m_error;
|
||||
QString m_errorString;
|
||||
|
||||
QString calculateAcceptKey(const QString &key) const;
|
||||
QString getHandshakeResponse(const QWebSocketHandshakeRequest &request,
|
||||
const QString &serverName,
|
||||
bool isOriginAllowed,
|
||||
const QList<QWebSocketProtocol::Version> &supportedVersions,
|
||||
const QList<QString> &supportedProtocols,
|
||||
const QList<QString> &supportedExtensions);
|
||||
|
||||
QTextStream &writeToStream(QTextStream &textStream) const;
|
||||
Q_AUTOTEST_EXPORT friend QTextStream & operator <<(QTextStream &stream,
|
||||
const QWebSocketHandshakeResponse &response);
|
||||
};
|
||||
|
||||
Q_AUTOTEST_EXPORT QTextStream & operator <<(QTextStream &stream,
|
||||
const QWebSocketHandshakeResponse &response);
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWEBSOCKETHANDSHAKERESPONSE_P_H
|
||||
@@ -0,0 +1,72 @@
|
||||
// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QWEBSOCKETPROTOCOL_P_H
|
||||
#define QWEBSOCKETPROTOCOL_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/private/qglobal_p.h>
|
||||
#include "QtWebSockets/qwebsocketprotocol.h"
|
||||
|
||||
#include <QtCore/qstringview.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QByteArray;
|
||||
|
||||
namespace QWebSocketProtocol
|
||||
{
|
||||
enum OpCode
|
||||
{
|
||||
OpCodeContinue = 0x0,
|
||||
OpCodeText = 0x1,
|
||||
OpCodeBinary = 0x2,
|
||||
OpCodeReserved3 = 0x3,
|
||||
OpCodeReserved4 = 0x4,
|
||||
OpCodeReserved5 = 0x5,
|
||||
OpCodeReserved6 = 0x6,
|
||||
OpCodeReserved7 = 0x7,
|
||||
OpCodeClose = 0x8,
|
||||
OpCodePing = 0x9,
|
||||
OpCodePong = 0xA,
|
||||
OpCodeReservedB = 0xB,
|
||||
OpCodeReservedC = 0xC,
|
||||
OpCodeReservedD = 0xD,
|
||||
OpCodeReservedE = 0xE,
|
||||
OpCodeReservedF = 0xF
|
||||
};
|
||||
|
||||
inline bool isOpCodeReserved(OpCode code)
|
||||
{
|
||||
return ((code > OpCodeBinary) && (code < OpCodeClose)) || (code > OpCodePong);
|
||||
}
|
||||
|
||||
inline bool isCloseCodeValid(int closeCode)
|
||||
{
|
||||
return (closeCode > 999) && (closeCode < 5000) &&
|
||||
(closeCode != CloseCodeReserved1004) && //see RFC6455 7.4.1
|
||||
(closeCode != CloseCodeMissingStatusCode) &&
|
||||
(closeCode != CloseCodeAbnormalDisconnection) &&
|
||||
((closeCode >= 3000) || (closeCode < 1012));
|
||||
}
|
||||
|
||||
inline Version currentVersion() { return VersionLatest; }
|
||||
Version Q_AUTOTEST_EXPORT versionFromString(QStringView versionString);
|
||||
|
||||
void Q_AUTOTEST_EXPORT mask(QByteArray *payload, quint32 maskingKey);
|
||||
void Q_AUTOTEST_EXPORT mask(char *payload, quint64 size, quint32 maskingKey);
|
||||
} //end namespace QWebSocketProtocol
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWEBSOCKETPROTOCOL_P_H
|
||||
@@ -0,0 +1,120 @@
|
||||
// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QWEBSOCKETSERVER_P_H
|
||||
#define QWEBSOCKETSERVER_P_H
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QQueue>
|
||||
#include <QtCore/QString>
|
||||
#include <QtNetwork/QHostAddress>
|
||||
#include <private/qobject_p.h>
|
||||
#include "qwebsocketserver.h"
|
||||
#include "qwebsocket.h"
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#include <QtNetwork/QSslConfiguration>
|
||||
#include <QtNetwork/QSslError>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QTcpServer;
|
||||
class QTcpSocket;
|
||||
|
||||
class QWebSocketServerPrivate : public QObjectPrivate
|
||||
{
|
||||
Q_DISABLE_COPY(QWebSocketServerPrivate)
|
||||
|
||||
public:
|
||||
Q_DECLARE_PUBLIC(QWebSocketServer)
|
||||
enum SslMode
|
||||
{
|
||||
SecureMode = true,
|
||||
NonSecureMode
|
||||
};
|
||||
|
||||
explicit QWebSocketServerPrivate(const QString &serverName, SslMode secureMode);
|
||||
~QWebSocketServerPrivate() override;
|
||||
|
||||
void init();
|
||||
void close(bool aboutToDestroy = false);
|
||||
QString errorString() const;
|
||||
bool hasPendingConnections() const;
|
||||
bool isListening() const;
|
||||
bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
|
||||
int maxPendingConnections() const;
|
||||
int handshakeTimeout() const {
|
||||
return m_handshakeTimeout;
|
||||
}
|
||||
virtual QWebSocket *nextPendingConnection();
|
||||
void pauseAccepting();
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QNetworkProxy proxy() const;
|
||||
void setProxy(const QNetworkProxy &networkProxy);
|
||||
#endif
|
||||
void resumeAccepting();
|
||||
QHostAddress serverAddress() const;
|
||||
QWebSocketProtocol::CloseCode serverError() const;
|
||||
quint16 serverPort() const;
|
||||
void setMaxPendingConnections(int numConnections);
|
||||
void setHandshakeTimeout(int msec);
|
||||
bool setSocketDescriptor(qintptr socketDescriptor);
|
||||
qintptr socketDescriptor() const;
|
||||
|
||||
QList<QWebSocketProtocol::Version> supportedVersions() const;
|
||||
void setSupportedSubprotocols(const QStringList &protocols);
|
||||
QStringList supportedSubprotocols() const;
|
||||
QStringList supportedExtensions() const;
|
||||
|
||||
void setServerName(const QString &serverName);
|
||||
QString serverName() const;
|
||||
|
||||
SslMode secureMode() const;
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
void setSslConfiguration(const QSslConfiguration &sslConfiguration);
|
||||
QSslConfiguration sslConfiguration() const;
|
||||
#endif
|
||||
|
||||
void setError(QWebSocketProtocol::CloseCode code, const QString &errorString);
|
||||
|
||||
void handleConnection(QTcpSocket *pTcpSocket) const;
|
||||
|
||||
private slots:
|
||||
void startHandshakeTimeout(QTcpSocket *pTcpSocket);
|
||||
|
||||
private:
|
||||
QTcpServer *m_pTcpServer;
|
||||
QString m_serverName;
|
||||
SslMode m_secureMode;
|
||||
QStringList m_supportedSubprotocols;
|
||||
QQueue<QWebSocket *> m_pendingConnections;
|
||||
QWebSocketProtocol::CloseCode m_error;
|
||||
QString m_errorString;
|
||||
int m_maxPendingConnections;
|
||||
int m_handshakeTimeout;
|
||||
|
||||
void addPendingConnection(QWebSocket *pWebSocket);
|
||||
void setErrorFromSocketError(QAbstractSocket::SocketError error,
|
||||
const QString &errorDescription);
|
||||
|
||||
void onNewConnection();
|
||||
void onSocketDisconnected();
|
||||
void handshakeReceived();
|
||||
void finishHandshakeTimeout(QTcpSocket *pTcpSocket);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWEBSOCKETSERVER_P_H
|
||||
@@ -0,0 +1 @@
|
||||
#include "qmaskgenerator.h"
|
||||
1
paho-mqtt3as-proxy/Qt/include/QtWebSockets/QWebSocket
Normal file
1
paho-mqtt3as-proxy/Qt/include/QtWebSockets/QWebSocket
Normal file
@@ -0,0 +1 @@
|
||||
#include "qwebsocket.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "qwebsocketcorsauthenticator.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "qwebsockethandshakeoptions.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "qwebsocketprotocol.h"
|
||||
@@ -0,0 +1 @@
|
||||
#include "qwebsocketserver.h"
|
||||
11
paho-mqtt3as-proxy/Qt/include/QtWebSockets/QtWebSockets
Normal file
11
paho-mqtt3as-proxy/Qt/include/QtWebSockets/QtWebSockets
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef QT_QTWEBSOCKETS_MODULE_H
|
||||
#define QT_QTWEBSOCKETS_MODULE_H
|
||||
#include <QtWebSockets/QtWebSocketsDepends>
|
||||
#include "qmaskgenerator.h"
|
||||
#include "qtwebsocketsversion.h"
|
||||
#include "qwebsocket.h"
|
||||
#include "qwebsocketcorsauthenticator.h"
|
||||
#include "qwebsockethandshakeoptions.h"
|
||||
#include "qwebsocketprotocol.h"
|
||||
#include "qwebsocketserver.h"
|
||||
#endif
|
||||
@@ -0,0 +1,5 @@
|
||||
/* This file was generated by cmake with the info from WebSockets target. */
|
||||
#ifdef __cplusplus /* create empty PCH in C mode */
|
||||
# include <QtCore/QtCore>
|
||||
# include <QtNetwork/QtNetwork>
|
||||
#endif
|
||||
@@ -0,0 +1 @@
|
||||
#include "qtwebsocketsversion.h"
|
||||
26
paho-mqtt3as-proxy/Qt/include/QtWebSockets/qmaskgenerator.h
Normal file
26
paho-mqtt3as-proxy/Qt/include/QtWebSockets/qmaskgenerator.h
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QMASKGENERATOR_H
|
||||
#define QMASKGENERATOR_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include "QtWebSockets/qwebsockets_global.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Q_WEBSOCKETS_EXPORT QMaskGenerator : public QObject
|
||||
{
|
||||
Q_DISABLE_COPY(QMaskGenerator)
|
||||
|
||||
public:
|
||||
explicit QMaskGenerator(QObject *parent = nullptr);
|
||||
~QMaskGenerator() override;
|
||||
|
||||
virtual bool seed() = 0;
|
||||
virtual quint32 nextMask() = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QMASKGENERATOR_H
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef QTWEBSOCKETSEXPORTS_H
|
||||
#define QTWEBSOCKETSEXPORTS_H
|
||||
|
||||
#if defined(QT_SHARED) || !defined(QT_STATIC)
|
||||
# if defined(QT_BUILD_WEBSOCKETS_LIB)
|
||||
# define Q_WEBSOCKETS_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define Q_WEBSOCKETS_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define Q_WEBSOCKETS_EXPORT
|
||||
#endif
|
||||
|
||||
#if !defined(QT_BUILD_WEBSOCKETS_LIB) && !defined(QT_STATIC)
|
||||
/* outside library -> inline decl + defi */
|
||||
/* static builds treat everything as part of the library, so they never inline */
|
||||
# define QT_WEBSOCKETS_INLINE_SINCE(major, minor) inline
|
||||
# define QT_WEBSOCKETS_INLINE_IMPL_SINCE(major, minor) 1
|
||||
#elif defined(QT_WEBSOCKETS_BUILD_REMOVED_API)
|
||||
/* inside library, inside removed_api.cpp:
|
||||
* keep deprecated API -> non-inline decl;
|
||||
* remove deprecated API -> inline decl;
|
||||
* definition is always available */
|
||||
# define QT_WEBSOCKETS_INLINE_SINCE(major, minor) \
|
||||
QT_IF_DEPRECATED_SINCE(major, minor, inline, /* not inline */)
|
||||
# define QT_WEBSOCKETS_INLINE_IMPL_SINCE(major, minor) 1
|
||||
#else
|
||||
/* inside library, outside removed_api.cpp:
|
||||
* keep deprecated API -> non-inline decl, no defi;
|
||||
* remove deprecated API -> inline decl, defi */
|
||||
# define QT_WEBSOCKETS_INLINE_SINCE(major, minor) \
|
||||
QT_IF_DEPRECATED_SINCE(major, minor, inline, /* not inline */)
|
||||
# define QT_WEBSOCKETS_INLINE_IMPL_SINCE(major, minor) \
|
||||
QT_IF_DEPRECATED_SINCE(major, minor, 1, 0)
|
||||
#endif
|
||||
|
||||
#ifdef QT_WEBSOCKETS_BUILD_REMOVED_API
|
||||
# define QT_WEBSOCKETS_REMOVED_SINCE(major, minor) QT_DEPRECATED_SINCE(major, minor)
|
||||
#else
|
||||
# define QT_WEBSOCKETS_REMOVED_SINCE(major, minor) 0
|
||||
#endif
|
||||
|
||||
#endif // QTWEBSOCKETSEXPORTS_H
|
||||
@@ -0,0 +1,9 @@
|
||||
/* This file was generated by syncqt. */
|
||||
#ifndef QT_QTWEBSOCKETS_VERSION_H
|
||||
#define QT_QTWEBSOCKETS_VERSION_H
|
||||
|
||||
#define QTWEBSOCKETS_VERSION_STR "6.5.3"
|
||||
|
||||
#define QTWEBSOCKETS_VERSION 0x060503
|
||||
|
||||
#endif // QT_QTWEBSOCKETS_VERSION_H
|
||||
150
paho-mqtt3as-proxy/Qt/include/QtWebSockets/qwebsocket.h
Normal file
150
paho-mqtt3as-proxy/Qt/include/QtWebSockets/qwebsocket.h
Normal file
@@ -0,0 +1,150 @@
|
||||
// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QWEBSOCKET_H
|
||||
#define QWEBSOCKET_H
|
||||
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtNetwork/QAbstractSocket>
|
||||
#include <QtNetwork/QNetworkRequest>
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#include <QtNetwork/QNetworkProxy>
|
||||
#endif
|
||||
#ifndef QT_NO_SSL
|
||||
#include <QtNetwork/QSslError>
|
||||
#include <QtNetwork/QSslConfiguration>
|
||||
#endif
|
||||
#include "QtWebSockets/qwebsockets_global.h"
|
||||
#include "QtWebSockets/qwebsocketprotocol.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QTcpSocket;
|
||||
class QWebSocketPrivate;
|
||||
class QMaskGenerator;
|
||||
class QWebSocketHandshakeOptions;
|
||||
|
||||
class Q_WEBSOCKETS_EXPORT QWebSocket : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(QWebSocket)
|
||||
Q_DECLARE_PRIVATE(QWebSocket)
|
||||
|
||||
public:
|
||||
explicit QWebSocket(const QString &origin = QString(),
|
||||
QWebSocketProtocol::Version version = QWebSocketProtocol::VersionLatest,
|
||||
QObject *parent = nullptr);
|
||||
~QWebSocket() override;
|
||||
|
||||
void abort();
|
||||
QAbstractSocket::SocketError error() const;
|
||||
QString errorString() const;
|
||||
bool flush();
|
||||
bool isValid() const;
|
||||
QHostAddress localAddress() const;
|
||||
quint16 localPort() const;
|
||||
QAbstractSocket::PauseModes pauseMode() const;
|
||||
QHostAddress peerAddress() const;
|
||||
QString peerName() const;
|
||||
quint16 peerPort() const;
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
QNetworkProxy proxy() const;
|
||||
void setProxy(const QNetworkProxy &networkProxy);
|
||||
#endif
|
||||
void setMaskGenerator(const QMaskGenerator *maskGenerator);
|
||||
const QMaskGenerator *maskGenerator() const;
|
||||
qint64 readBufferSize() const;
|
||||
void setReadBufferSize(qint64 size);
|
||||
|
||||
void resume();
|
||||
void setPauseMode(QAbstractSocket::PauseModes pauseMode);
|
||||
|
||||
QAbstractSocket::SocketState state() const;
|
||||
|
||||
QWebSocketProtocol::Version version() const;
|
||||
QString resourceName() const;
|
||||
QUrl requestUrl() const;
|
||||
QNetworkRequest request() const;
|
||||
QWebSocketHandshakeOptions handshakeOptions() const;
|
||||
QString origin() const;
|
||||
QString subprotocol() const;
|
||||
QWebSocketProtocol::CloseCode closeCode() const;
|
||||
QString closeReason() const;
|
||||
|
||||
qint64 sendTextMessage(const QString &message);
|
||||
qint64 sendBinaryMessage(const QByteArray &data);
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
void ignoreSslErrors(const QList<QSslError> &errors);
|
||||
void continueInterruptedHandshake();
|
||||
|
||||
void setSslConfiguration(const QSslConfiguration &sslConfiguration);
|
||||
QSslConfiguration sslConfiguration() const;
|
||||
#endif
|
||||
|
||||
qint64 bytesToWrite() const;
|
||||
|
||||
void setMaxAllowedIncomingFrameSize(quint64 maxAllowedIncomingFrameSize);
|
||||
quint64 maxAllowedIncomingFrameSize() const;
|
||||
void setMaxAllowedIncomingMessageSize(quint64 maxAllowedIncomingMessageSize);
|
||||
quint64 maxAllowedIncomingMessageSize() const;
|
||||
static quint64 maxIncomingMessageSize();
|
||||
static quint64 maxIncomingFrameSize();
|
||||
|
||||
void setOutgoingFrameSize(quint64 outgoingFrameSize);
|
||||
quint64 outgoingFrameSize() const;
|
||||
static quint64 maxOutgoingFrameSize();
|
||||
|
||||
public Q_SLOTS:
|
||||
void close(QWebSocketProtocol::CloseCode closeCode = QWebSocketProtocol::CloseCodeNormal,
|
||||
const QString &reason = QString());
|
||||
|
||||
// ### Qt7: Merge overloads
|
||||
void open(const QUrl &url);
|
||||
void open(const QNetworkRequest &request);
|
||||
void open(const QUrl &url, const QWebSocketHandshakeOptions &options);
|
||||
void open(const QNetworkRequest &request, const QWebSocketHandshakeOptions &options);
|
||||
|
||||
void ping(const QByteArray &payload = QByteArray());
|
||||
#ifndef QT_NO_SSL
|
||||
void ignoreSslErrors();
|
||||
#endif
|
||||
|
||||
Q_SIGNALS:
|
||||
void aboutToClose();
|
||||
void connected();
|
||||
void disconnected();
|
||||
void stateChanged(QAbstractSocket::SocketState state);
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *pAuthenticator);
|
||||
#endif
|
||||
void readChannelFinished();
|
||||
void textFrameReceived(const QString &frame, bool isLastFrame);
|
||||
void binaryFrameReceived(const QByteArray &frame, bool isLastFrame);
|
||||
void textMessageReceived(const QString &message);
|
||||
void binaryMessageReceived(const QByteArray &message);
|
||||
#if QT_DEPRECATED_SINCE(6, 5)
|
||||
QT_DEPRECATED_VERSION_X_6_5("Use errorOccurred instead")
|
||||
void error(QAbstractSocket::SocketError error);
|
||||
#endif
|
||||
void errorOccurred(QAbstractSocket::SocketError error);
|
||||
void pong(quint64 elapsedTime, const QByteArray &payload);
|
||||
void bytesWritten(qint64 bytes);
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
void peerVerifyError(const QSslError &error);
|
||||
void sslErrors(const QList<QSslError> &errors);
|
||||
void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator);
|
||||
void alertSent(QSsl::AlertLevel level, QSsl::AlertType type, const QString &description);
|
||||
void alertReceived(QSsl::AlertLevel level, QSsl::AlertType type, const QString &description);
|
||||
void handshakeInterruptedOnError(const QSslError &error);
|
||||
#endif
|
||||
|
||||
private:
|
||||
QWebSocket(QTcpSocket *pTcpSocket, QWebSocketProtocol::Version version,
|
||||
QObject *parent = nullptr);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWEBSOCKET_H
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
#ifndef QWEBSOCKETCORSAUTHENTICATOR_H
|
||||
#define QWEBSOCKETCORSAUTHENTICATOR_H
|
||||
|
||||
#include "QtWebSockets/qwebsockets_global.h"
|
||||
#include <memory>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWebSocketCorsAuthenticatorPrivate;
|
||||
|
||||
class Q_WEBSOCKETS_EXPORT QWebSocketCorsAuthenticator
|
||||
{
|
||||
Q_DECLARE_PRIVATE(QWebSocketCorsAuthenticator)
|
||||
|
||||
public:
|
||||
explicit QWebSocketCorsAuthenticator(const QString &origin);
|
||||
~QWebSocketCorsAuthenticator();
|
||||
explicit QWebSocketCorsAuthenticator(const QWebSocketCorsAuthenticator &other);
|
||||
|
||||
QWebSocketCorsAuthenticator(QWebSocketCorsAuthenticator &&other) noexcept;
|
||||
QWebSocketCorsAuthenticator &operator =(QWebSocketCorsAuthenticator &&other) noexcept;
|
||||
|
||||
void swap(QWebSocketCorsAuthenticator &other) noexcept;
|
||||
|
||||
QWebSocketCorsAuthenticator &operator =(const QWebSocketCorsAuthenticator &other);
|
||||
|
||||
QString origin() const;
|
||||
|
||||
void setAllowed(bool allowed);
|
||||
bool allowed() const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<QWebSocketCorsAuthenticatorPrivate> d_ptr;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWEBSOCKETCORSAUTHENTICATOR_H
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2022 Menlo Systems GmbH, author Arno Rehn <a.rehn@menlosystems.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
|
||||
#ifndef QWEBSOCKETHANDSHAKEOPTIONS_H
|
||||
#define QWEBSOCKETHANDSHAKEOPTIONS_H
|
||||
|
||||
#include <QtCore/QSharedDataPointer>
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
#include "QtWebSockets/qwebsockets_global.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QWebSocketHandshakeOptionsPrivate;
|
||||
|
||||
QT_DECLARE_QSDP_SPECIALIZATION_DTOR_WITH_EXPORT(QWebSocketHandshakeOptionsPrivate, Q_WEBSOCKETS_EXPORT)
|
||||
|
||||
class Q_WEBSOCKETS_EXPORT QWebSocketHandshakeOptions
|
||||
{
|
||||
public:
|
||||
QWebSocketHandshakeOptions();
|
||||
QWebSocketHandshakeOptions(const QWebSocketHandshakeOptions &other);
|
||||
QWebSocketHandshakeOptions(QWebSocketHandshakeOptions &&other) noexcept = default;
|
||||
~QWebSocketHandshakeOptions();
|
||||
|
||||
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QWebSocketHandshakeOptions)
|
||||
QWebSocketHandshakeOptions &operator=(const QWebSocketHandshakeOptions &other);
|
||||
|
||||
void swap(QWebSocketHandshakeOptions &other) noexcept { d.swap(other.d); }
|
||||
|
||||
QStringList subprotocols() const;
|
||||
void setSubprotocols(const QStringList &protocols);
|
||||
|
||||
private:
|
||||
bool equals(const QWebSocketHandshakeOptions &other) const;
|
||||
|
||||
friend bool operator==(const QWebSocketHandshakeOptions &lhs,
|
||||
const QWebSocketHandshakeOptions &rhs) { return lhs.equals(rhs); }
|
||||
friend bool operator!=(const QWebSocketHandshakeOptions &lhs,
|
||||
const QWebSocketHandshakeOptions &rhs) { return !lhs.equals(rhs); }
|
||||
|
||||
QSharedDataPointer<QWebSocketHandshakeOptionsPrivate> d;
|
||||
friend class QWebSocketHandshakeOptionsPrivate;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWEBSOCKETHANDSHAKEOPTIONS_H
|
||||
@@ -0,0 +1,55 @@
|
||||
// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QWEBSOCKETPROTOCOL_H
|
||||
#define QWEBSOCKETPROTOCOL_H
|
||||
|
||||
#if 0
|
||||
# pragma qt_class(QWebSocketProtocol)
|
||||
#endif
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include "QtWebSockets/qwebsockets_global.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QString;
|
||||
|
||||
namespace QWebSocketProtocol
|
||||
{
|
||||
enum Version
|
||||
{
|
||||
VersionUnknown = -1,
|
||||
Version0 = 0,
|
||||
//hybi-01, hybi-02 and hybi-03 not supported
|
||||
Version4 = 4,
|
||||
Version5 = 5,
|
||||
Version6 = 6,
|
||||
Version7 = 7,
|
||||
Version8 = 8,
|
||||
Version13 = 13,
|
||||
VersionLatest = Version13
|
||||
};
|
||||
|
||||
enum CloseCode
|
||||
{
|
||||
CloseCodeNormal = 1000,
|
||||
CloseCodeGoingAway = 1001,
|
||||
CloseCodeProtocolError = 1002,
|
||||
CloseCodeDatatypeNotSupported = 1003,
|
||||
CloseCodeReserved1004 = 1004,
|
||||
CloseCodeMissingStatusCode = 1005,
|
||||
CloseCodeAbnormalDisconnection = 1006,
|
||||
CloseCodeWrongDatatype = 1007,
|
||||
CloseCodePolicyViolated = 1008,
|
||||
CloseCodeTooMuchData = 1009,
|
||||
CloseCodeMissingExtension = 1010,
|
||||
CloseCodeBadOperation = 1011,
|
||||
CloseCodeTlsHandshakeFailed = 1015
|
||||
};
|
||||
|
||||
} //end namespace QWebSocketProtocol
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWEBSOCKETPROTOCOL_H
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QWEBSOCKETSGLOBAL_H
|
||||
#define QWEBSOCKETSGLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtWebSockets/qtwebsocketsexports.h>
|
||||
|
||||
#endif // QWEBSOCKETSGLOBAL_H
|
||||
133
paho-mqtt3as-proxy/Qt/include/QtWebSockets/qwebsocketserver.h
Normal file
133
paho-mqtt3as-proxy/Qt/include/QtWebSockets/qwebsocketserver.h
Normal file
@@ -0,0 +1,133 @@
|
||||
// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QWEBSOCKETSERVER_H
|
||||
#define QWEBSOCKETSERVER_H
|
||||
|
||||
#include "QtWebSockets/qwebsockets_global.h"
|
||||
#include "QtWebSockets/qwebsocketprotocol.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QString>
|
||||
#include <QtNetwork/QHostAddress>
|
||||
|
||||
#ifndef QT_NO_SSL
|
||||
#include <QtNetwork/QSslConfiguration>
|
||||
#include <QtNetwork/QSslError>
|
||||
#endif
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
#include <chrono>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QTcpSocket;
|
||||
class QWebSocketServerPrivate;
|
||||
class QWebSocket;
|
||||
class QWebSocketCorsAuthenticator;
|
||||
|
||||
class Q_WEBSOCKETS_EXPORT QWebSocketServer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(QWebSocketServer)
|
||||
Q_DECLARE_PRIVATE(QWebSocketServer)
|
||||
|
||||
public:
|
||||
enum SslMode {
|
||||
#ifndef QT_NO_SSL
|
||||
SecureMode = 0,
|
||||
#endif
|
||||
NonSecureMode = 1
|
||||
};
|
||||
Q_ENUM(SslMode)
|
||||
|
||||
explicit QWebSocketServer(const QString &serverName, SslMode secureMode,
|
||||
QObject *parent = nullptr);
|
||||
~QWebSocketServer() override;
|
||||
|
||||
bool listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
|
||||
void close();
|
||||
|
||||
bool isListening() const;
|
||||
|
||||
void setMaxPendingConnections(int numConnections);
|
||||
int maxPendingConnections() const;
|
||||
|
||||
#if __has_include(<chrono>) || defined(Q_QDOC)
|
||||
void setHandshakeTimeout(std::chrono::milliseconds msec)
|
||||
{
|
||||
setHandshakeTimeout(int(msec.count()));
|
||||
}
|
||||
std::chrono::milliseconds handshakeTimeout() const
|
||||
{
|
||||
return std::chrono::milliseconds(handshakeTimeoutMS());
|
||||
}
|
||||
#endif
|
||||
void setHandshakeTimeout(int msec);
|
||||
int handshakeTimeoutMS() const;
|
||||
|
||||
quint16 serverPort() const;
|
||||
QHostAddress serverAddress() const;
|
||||
QUrl serverUrl() const;
|
||||
|
||||
SslMode secureMode() const;
|
||||
|
||||
bool setSocketDescriptor(qintptr socketDescriptor);
|
||||
qintptr socketDescriptor() const;
|
||||
#if QT_DEPRECATED_SINCE(6, 2)
|
||||
QT_DEPRECATED_VERSION_X_6_2("Use setSocketDescriptor instead")
|
||||
bool setNativeDescriptor(qintptr descriptor) { return setSocketDescriptor(descriptor); }
|
||||
QT_DEPRECATED_VERSION_X_6_2("Use socketDescriptor instead")
|
||||
qintptr nativeDescriptor() const { return socketDescriptor(); }
|
||||
#endif
|
||||
|
||||
bool hasPendingConnections() const;
|
||||
virtual QWebSocket *nextPendingConnection();
|
||||
|
||||
QWebSocketProtocol::CloseCode error() const;
|
||||
QString errorString() const;
|
||||
|
||||
void pauseAccepting();
|
||||
void resumeAccepting();
|
||||
|
||||
void setServerName(const QString &serverName);
|
||||
QString serverName() const;
|
||||
|
||||
void setSupportedSubprotocols(const QStringList &protocols);
|
||||
QStringList supportedSubprotocols() const;
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void setProxy(const QNetworkProxy &networkProxy);
|
||||
QNetworkProxy proxy() const;
|
||||
#endif
|
||||
#ifndef QT_NO_SSL
|
||||
void setSslConfiguration(const QSslConfiguration &sslConfiguration);
|
||||
QSslConfiguration sslConfiguration() const;
|
||||
#endif
|
||||
|
||||
QList<QWebSocketProtocol::Version> supportedVersions() const;
|
||||
|
||||
void handleConnection(QTcpSocket *socket) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void acceptError(QAbstractSocket::SocketError socketError);
|
||||
void serverError(QWebSocketProtocol::CloseCode closeCode);
|
||||
//TODO: should use a delegate iso of a synchronous signal
|
||||
//see also QTBUG-16251
|
||||
void originAuthenticationRequired(QWebSocketCorsAuthenticator *pAuthenticator);
|
||||
void newConnection();
|
||||
#ifndef QT_NO_SSL
|
||||
void peerVerifyError(const QSslError &error);
|
||||
void sslErrors(const QList<QSslError> &errors);
|
||||
void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator);
|
||||
void alertSent(QSsl::AlertLevel level, QSsl::AlertType type, const QString &description);
|
||||
void alertReceived(QSsl::AlertLevel level, QSsl::AlertType type, const QString &description);
|
||||
void handshakeInterruptedOnError(const QSslError &error);
|
||||
#endif
|
||||
void closed();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QWEBSOCKETSERVER_H
|
||||
Reference in New Issue
Block a user