diff --git a/src/websockets/qdefaultmaskgenerator_p.cpp b/src/websockets/qdefaultmaskgenerator_p.cpp index 814e04d97d5f5fe1774b37f1a033b89bc07b6782..da166aca4ef43b3478a53a33389daf2fe761a4ac 100644 --- a/src/websockets/qdefaultmaskgenerator_p.cpp +++ b/src/websockets/qdefaultmaskgenerator_p.cpp @@ -38,6 +38,26 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +/*! + \class QDefaultMaskGenerator + + \inmodule QtWebSockets + + \brief The QDefaultMaskGenerator class provides the default mask generator for QtWebSockets. + + The WebSockets specification as outlined in {http://tools.ietf.org/html/rfc6455}{RFC 6455} + requires that all communication from client to server must be masked. This is to prevent + malicious scripts to attack bad behaving proxies. + For more information about the importance of good masking, + see \l {http://w2spconf.com/2011/papers/websocket.pdf}. + The default mask generator uses the cryptographically insecure qrand() function. + The best measure against attacks mentioned in the document above, + is to use QWebSocket over a secure connection (\e wss://). + In general, always be careful to not have 3rd party script access to + a QWebSocket in your application. + + \internal +*/ #include "qdefaultmaskgenerator_p.h" #include <QDateTime> @@ -45,21 +65,42 @@ QT_BEGIN_NAMESPACE +/*! + Constructs a new QDefaultMaskGenerator with the given \a parent. + + \internal +*/ QDefaultMaskGenerator::QDefaultMaskGenerator(QObject *parent) : QMaskGenerator(parent) { } +/*! + Destroys the QDefaultMaskGenerator object. + + \internal +*/ QDefaultMaskGenerator::~QDefaultMaskGenerator() { } +/*! + Seeds the QDefaultMaskGenerator using qsrand(). + When seed() is not called, no seed is used at all. + + \internal +*/ bool QDefaultMaskGenerator::seed() { qsrand(static_cast<uint>(QDateTime::currentMSecsSinceEpoch())); return true; } +/*! + Generates a new random mask using the insecure qrand() method. + + \internal +*/ quint32 QDefaultMaskGenerator::nextMask() { return quint32((double(qrand()) / RAND_MAX) * std::numeric_limits<quint32>::max()); diff --git a/src/websockets/qmaskgenerator.cpp b/src/websockets/qmaskgenerator.cpp index 3e4ce1796a3017a89ffa18475e81f28460525c2f..04f5e1e1f6b296eb1f1e540d75043af7d2e80e37 100644 --- a/src/websockets/qmaskgenerator.cpp +++ b/src/websockets/qmaskgenerator.cpp @@ -41,6 +41,7 @@ /*! \class QMaskGenerator + \inmodule QtWebSockets \brief The QMaskGenerator class provides an abstract base for custom 32-bit mask generators. diff --git a/src/websockets/qsslserver.cpp b/src/websockets/qsslserver.cpp index d1add194f0000c8b53122f13a30bbeb217c48134..e5faded3526a1e7f094a16194997c84c9e8164a3 100644 --- a/src/websockets/qsslserver.cpp +++ b/src/websockets/qsslserver.cpp @@ -39,6 +39,16 @@ ** ****************************************************************************/ +/*! + \class QSslServer + + \inmodule QtWebSockets + + \brief Implements a secure TCP server over SSL. + + \internal +*/ + #include "qsslserver_p.h" #include <QtNetwork/QSslSocket> @@ -46,26 +56,57 @@ QT_BEGIN_NAMESPACE +/*! + Constructs a new QSslServer with the given \a parent. + + \internal +*/ QSslServer::QSslServer(QObject *parent) : QTcpServer(parent), m_sslConfiguration(QSslConfiguration::defaultConfiguration()) { } +/*! + Destroys the QSslServer. + + All open connections are closed. + + \internal +*/ QSslServer::~QSslServer() { } +/*! + Sets the \a sslConfiguration to use. + + \sa QSslSocket::setSslConfiguration() + + \internal +*/ void QSslServer::setSslConfiguration(const QSslConfiguration &sslConfiguration) { m_sslConfiguration = sslConfiguration; } +/*! + Returns the current ssl configuration. + + \internal +*/ QSslConfiguration QSslServer::sslConfiguration() const { return m_sslConfiguration; } +/*! + Called when a new connection is established. + + Converts \a socket to a QSslSocket. + + \internal +*/ void QSslServer::incomingConnection(qintptr socket) { QSslSocket *pSslSocket = new QSslSocket(); diff --git a/src/websockets/qwebsocket.cpp b/src/websockets/qwebsocket.cpp index 707d459d88993ea40dac771f16dfdf8605b57160..85b45c0278e39976918ae7fe18a6d26c8582a666 100644 --- a/src/websockets/qwebsocket.cpp +++ b/src/websockets/qwebsocket.cpp @@ -60,6 +60,10 @@ QWebSocket only supports version 13 of the WebSocket protocol, as outlined in \l {http://tools.ietf.org/html/rfc6455}{RFC 6455}. + \note Some proxies do not understand certain HTTP headers used during a web socket handshake. + In that case, non-secure web socket connections fail. The best way to mitigate against + this problem is to use web sockets over a secure connection. + \warning To generate masks, this implementation of WebSockets uses the cryptographically insecure qrand() function. For more information about the importance of good masking,