| 74 | } |
| 75 | |
| 76 | void QtHttpServer::onClientConnected(void) |
| 77 | { |
| 78 | while (m_sockServer->hasPendingConnections()) |
| 79 | { |
| 80 | if (QTcpSocket* sock = m_sockServer->nextPendingConnection()) |
| 81 | { |
| 82 | if (m_netOrigin->accessAllowed(sock->peerAddress(), sock->localAddress())) |
| 83 | { |
| 84 | connect(sock, &QTcpSocket::disconnected, this, &QtHttpServer::onClientDisconnected); |
| 85 | |
| 86 | if (m_useSsl) |
| 87 | { |
| 88 | if (QSslSocket* ssl = qobject_cast<QSslSocket*> (sock)) |
| 89 | { |
| 90 | connect(ssl, SslErrorSignal(&QSslSocket::sslErrors), this, &QtHttpServer::onClientSslErrors); |
| 91 | connect(ssl, &QSslSocket::encrypted, this, &QtHttpServer::onClientSslEncrypted); |
| 92 | connect(ssl, &QSslSocket::peerVerifyError, this, &QtHttpServer::onClientSslPeerVerifyError); |
| 93 | connect(ssl, &QSslSocket::modeChanged, this, &QtHttpServer::onClientSslModeChanged); |
| 94 | ssl->setLocalCertificateChain(m_sslCerts); |
| 95 | ssl->setPrivateKey(m_sslKey); |
| 96 | ssl->setPeerVerifyMode(QSslSocket::AutoVerifyPeer); |
| 97 | ssl->startServerEncryption(); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | QtHttpClientWrapper* wrapper = new QtHttpClientWrapper( |
| 102 | sock, m_netOrigin->isLocalAddress(sock->peerAddress(), sock->localAddress()), this); |
| 103 | m_socksClientsHash.insert(sock, wrapper); |
| 104 | emit clientConnected(wrapper->getGuid()); |
| 105 | } |
| 106 | else |
| 107 | { |
| 108 | sock->close(); |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | void QtHttpServer::onClientDisconnected(void) |
| 115 | { |
nothing calls this directly
no test coverage detected