1// Copyright (C) 2022 The Qt Company Ltd.
2// Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QSSLSERVER_P_H
6#define QSSLSERVER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtNetwork/private/qtnetworkglobal_p.h>
20
21#include <QtCore/qhash.h>
22#include <QtCore/qtimer.h>
23
24#include <QtNetwork/QSslConfiguration>
25#include <QtNetwork/private/qtcpserver_p.h>
26#include <utility>
27
28QT_BEGIN_NAMESPACE
29
30class Q_NETWORK_EXPORT QSslServerPrivate : public QTcpServerPrivate
31{
32 static constexpr int DefaultHandshakeTimeout = 5'000; // 5 seconds
33public:
34 Q_DECLARE_PUBLIC(QSslServer)
35
36 QSslServerPrivate();
37 void checkClientHelloAndContinue();
38 void initializeHandshakeProcess(QSslSocket *socket);
39 void removeSocketData(quintptr socket);
40 void handleHandshakeTimedOut(QSslSocket *socket);
41 int totalPendingConnections() const override;
42
43 struct SocketData {
44 QMetaObject::Connection readyReadConnection;
45 QMetaObject::Connection destroyedConnection;
46 std::shared_ptr<QTimer> timeoutTimer; // shared_ptr because QHash demands copying
47
48 SocketData(QMetaObject::Connection readyRead, QMetaObject::Connection destroyed,
49 std::shared_ptr<QTimer> &&timer)
50 : readyReadConnection(readyRead),
51 destroyedConnection(destroyed),
52 timeoutTimer(std::move(timer))
53 {
54 }
55
56 void disconnectSignals()
57 {
58 QObject::disconnect(std::exchange(obj&: readyReadConnection, new_val: {}));
59 QObject::disconnect(std::exchange(obj&: destroyedConnection, new_val: {}));
60 }
61 };
62 QHash<quintptr, SocketData> socketData;
63
64 QSslConfiguration sslConfiguration;
65 int handshakeTimeout = DefaultHandshakeTimeout;
66};
67
68
69QT_END_NAMESPACE
70
71#endif // QSSLSERVER_P_H
72

source code of qtbase/src/network/ssl/qsslserver_p.h