5#include "tcpsslserver.h"
17TcpSslServer::TcpSslServer(
const QByteArray &serverAddress,
21 :
TcpServer(serverAddress, protocol, wsgi, parent)
25void TcpSslServer::incomingConnection(qintptr handle)
27 auto sock =
new SslSocket(m_engine,
this);
28 sock->protoData = m_protocol->createData(sock);
29 sock->setSslConfiguration(m_sslConfiguration);
32 sock->timeout =
false;
33 sock->proto->parse(sock, sock);
35 connect(sock, &SslSocket::finished,
this, [
this, sock]() {
37 if (--m_processing == 0) {
38 m_engine->stopSocketTimeout();
42 if (Q_LIKELY(sock->setSocketDescriptor(
44 sock->proto = m_protocol;
46 sock->serverAddress = m_serverAddress;
47 sock->remoteAddress = sock->peerAddress();
48 sock->remotePort = sock->peerPort();
49 sock->protoData->setupNewConnection(sock);
51 for (
const auto &opt : m_socketOptions) {
52 sock->setSocketOption(opt.first, opt.second);
56 m_engine->startSocketTimeout();
59 sock->startServerEncryption();
60 if (m_http2Protocol) {
62 if (sock->sslConfiguration().nextNegotiatedProtocol() ==
"h2") {
63 sock->proto = m_http2Protocol;
64 sock->protoData = sock->proto->createData(sock);
73void TcpSslServer::shutdown()
77 if (m_processing == 0) {
78 m_engine->serverShutdown();
81 for (
auto child : childrenL) {
82 auto socket = qobject_cast<TcpSocket *>(child);
84 connect(socket, &TcpSocket::finished,
this, [
this]() {
86 m_engine->serverShutdown();
89 m_engine->handleSocketShutdown(socket);
95void TcpSslServer::timeoutConnections()
99 for (
auto child : childrenL) {
100 auto socket = qobject_cast<SslSocket *>(child);
101 if (socket && !socket->processing &&
103 if (socket->timeout) {
104 socket->connectionClose();
106 socket->timeout =
true;
115 m_sslConfiguration = conf;
119void TcpSslServer::setHttp2Protocol(
Protocol *protocol)
121 m_http2Protocol = protocol;
124# include "moc_tcpsslserver.cpp"
The Cutelyst namespace holds all public Cutelyst API.
const QObjectList & children() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QList< QByteArray > allowedNextProtocols() const const