| 1 | // Copyright (C) 2024 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | // Qt-Security score:significant reason:default |
| 4 | |
| 5 | #ifndef QHTTPSERVERCONFIGURATION_H |
| 6 | #define QHTTPSERVERCONFIGURATION_H |
| 7 | |
| 8 | #include <QtHttpServer/qthttpserverglobal.h> |
| 9 | |
| 10 | #include <QtCore/qshareddata.h> |
| 11 | #include <QtCore/qlist.h> |
| 12 | #include <QtNetwork/qhostaddress.h> |
| 13 | |
| 14 | #include <chrono> |
| 15 | |
| 16 | QT_BEGIN_NAMESPACE |
| 17 | |
| 18 | class QHttpServerConfigurationPrivate; |
| 19 | QT_DECLARE_QESDP_SPECIALIZATION_DTOR(QHttpServerConfigurationPrivate) |
| 20 | |
| 21 | class QHttpServerConfiguration |
| 22 | { |
| 23 | public: |
| 24 | Q_HTTPSERVER_EXPORT QHttpServerConfiguration(); |
| 25 | Q_HTTPSERVER_EXPORT QHttpServerConfiguration(const QHttpServerConfiguration &other); |
| 26 | QHttpServerConfiguration(QHttpServerConfiguration &&other) noexcept = default; |
| 27 | Q_HTTPSERVER_EXPORT QHttpServerConfiguration &operator = (const QHttpServerConfiguration &other); |
| 28 | |
| 29 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QHttpServerConfiguration) |
| 30 | void swap(QHttpServerConfiguration &other) noexcept { d.swap(other&: other.d); } |
| 31 | |
| 32 | Q_HTTPSERVER_EXPORT ~QHttpServerConfiguration(); |
| 33 | |
| 34 | Q_HTTPSERVER_EXPORT void setRateLimitPerSecond(quint32 maxRequests); |
| 35 | Q_HTTPSERVER_EXPORT quint32 rateLimitPerSecond() const; |
| 36 | |
| 37 | Q_HTTPSERVER_EXPORT void setKeepAliveTimeout(std::chrono::seconds timeout); |
| 38 | Q_HTTPSERVER_EXPORT std::chrono::seconds keepAliveTimeout() const; |
| 39 | |
| 40 | Q_HTTPSERVER_EXPORT void setWhitelist(QSpan<const std::pair<QHostAddress, int>> subnetList); |
| 41 | Q_HTTPSERVER_EXPORT QSpan<const std::pair<QHostAddress, int>> whitelist() const; |
| 42 | |
| 43 | Q_HTTPSERVER_EXPORT void setBlacklist(QSpan<const std::pair<QHostAddress, int>> subnetList); |
| 44 | Q_HTTPSERVER_EXPORT QSpan<const std::pair<QHostAddress, int>> blacklist() const; |
| 45 | |
| 46 | private: |
| 47 | QExplicitlySharedDataPointer<QHttpServerConfigurationPrivate> d; |
| 48 | |
| 49 | friend Q_HTTPSERVER_EXPORT bool |
| 50 | comparesEqual(const QHttpServerConfiguration &lhs, const QHttpServerConfiguration &rhs) noexcept; |
| 51 | Q_DECLARE_EQUALITY_COMPARABLE(QHttpServerConfiguration) |
| 52 | }; |
| 53 | Q_DECLARE_SHARED(QHttpServerConfiguration) |
| 54 | |
| 55 | QT_END_NAMESPACE |
| 56 | |
| 57 | #endif // QHTTPSERVERCONFIGURATION_H |
| 58 |
