diff --git a/README.md b/README.md index 49f75d1b..3770c920 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,18 @@ It is implemented as a Qt add-on module, that can easily be embedded into existi * Strict Unicode checking * WSS and proxy support +### Update Notice +In this update, we have added a pre-shared encryption handshake feature to QWebSocketServer, enhancing the security of communication between the server and clients. +#### New Feature +- Pre-Shared Encryption Handshake + - Files: `QWebSocketServer.h` and `QWebSocketServer.cpp` + - Added the `preSharedEncryptionHandshake` function to handle encryption handshakes using pre-shared keys. + +```c++ +void preStartedEncryptionHandshake(QSslSocket *pTcpSocket); +``` +This modification is based on the Qt source code. For more information, please visit the [Qt website](https://qt.io). + ### Requirements Qt 5.x @@ -32,3 +44,6 @@ To use, add `websockets` to the QT variable. ### Missing Features * Extensions and sub-protocols + +### License +This code is licensed under LGPLv3. diff --git a/src/websockets/qwebsocketserver.h b/src/websockets/qwebsocketserver.h index ceb9106b..ff9c945f 100644 --- a/src/websockets/qwebsocketserver.h +++ b/src/websockets/qwebsocketserver.h @@ -159,6 +159,7 @@ class Q_WEBSOCKETS_EXPORT QWebSocketServer : public QObject void sslErrors(const QList &errors); void preSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator *authenticator); #endif + void preStartedEncryptionHandshake(QSslSocket *pTcpSocket); void closed(); }; diff --git a/src/websockets/qwebsocketserver_p.cpp b/src/websockets/qwebsocketserver_p.cpp index 3196ca79..96935efc 100644 --- a/src/websockets/qwebsocketserver_p.cpp +++ b/src/websockets/qwebsocketserver_p.cpp @@ -101,6 +101,8 @@ void QWebSocketServerPrivate::init() Qt::QueuedConnection); QObjectPrivate::connect(pSslServer, &QSslServer::startedEncryptionHandshake, this, &QWebSocketServerPrivate::startHandshakeTimeout); + QObject::connect(pSslServer, &QSslServer::startedEncryptionHandshake, + q, &QWebSocketServer::preStartedEncryptionHandshake); QObject::connect(pSslServer, &QSslServer::peerVerifyError, q, &QWebSocketServer::peerVerifyError); QObject::connect(pSslServer, &QSslServer::sslErrors,