mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-23 00:47:21 -06:00
Refactor: move methods under the same #if section.
This commit is contained in:
committed by
sledgehammer999
parent
13f27c6d3b
commit
3987e677d5
@@ -60,6 +60,33 @@ Server::~Server()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Server::incomingConnection(qintptr socketDescriptor)
|
||||||
|
{
|
||||||
|
QTcpSocket *serverSocket;
|
||||||
|
#ifndef QT_NO_OPENSSL
|
||||||
|
if (m_https)
|
||||||
|
serverSocket = new QSslSocket(this);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
serverSocket = new QTcpSocket(this);
|
||||||
|
|
||||||
|
if (serverSocket->setSocketDescriptor(socketDescriptor)) {
|
||||||
|
#ifndef QT_NO_OPENSSL
|
||||||
|
if (m_https) {
|
||||||
|
static_cast<QSslSocket *>(serverSocket)->setProtocol(QSsl::SecureProtocols);
|
||||||
|
static_cast<QSslSocket *>(serverSocket)->setPrivateKey(m_key);
|
||||||
|
static_cast<QSslSocket *>(serverSocket)->setLocalCertificateChain(m_certificates);
|
||||||
|
static_cast<QSslSocket *>(serverSocket)->setPeerVerifyMode(QSslSocket::VerifyNone);
|
||||||
|
static_cast<QSslSocket *>(serverSocket)->startServerEncryption();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
new Connection(serverSocket, m_requestHandler, this);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
serverSocket->deleteLater();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
bool Server::setupHttps(const QByteArray &certificates, const QByteArray &key)
|
bool Server::setupHttps(const QByteArray &certificates, const QByteArray &key)
|
||||||
{
|
{
|
||||||
@@ -90,44 +117,15 @@ void Server::disableHttps()
|
|||||||
m_certificates.clear();
|
m_certificates.clear();
|
||||||
m_key.clear();
|
m_key.clear();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef QBT_USES_QT5
|
#ifdef QBT_USES_QT5
|
||||||
void Server::incomingConnection(qintptr socketDescriptor)
|
|
||||||
#else
|
#else
|
||||||
void Server::incomingConnection(int socketDescriptor)
|
void Server::incomingConnection(int socketDescriptor)
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
QTcpSocket *serverSocket;
|
|
||||||
#ifndef QT_NO_OPENSSL
|
|
||||||
if (m_https)
|
|
||||||
serverSocket = new QSslSocket(this);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
serverSocket = new QTcpSocket(this);
|
|
||||||
|
|
||||||
if (serverSocket->setSocketDescriptor(socketDescriptor)) {
|
|
||||||
#ifndef QT_NO_OPENSSL
|
|
||||||
if (m_https) {
|
|
||||||
static_cast<QSslSocket *>(serverSocket)->setProtocol(QSsl::SecureProtocols);
|
|
||||||
static_cast<QSslSocket *>(serverSocket)->setPrivateKey(m_key);
|
|
||||||
#ifdef QBT_USES_QT5
|
#ifdef QBT_USES_QT5
|
||||||
static_cast<QSslSocket *>(serverSocket)->setLocalCertificateChain(m_certificates);
|
|
||||||
#else
|
#else
|
||||||
static_cast<QSslSocket *>(serverSocket)->setLocalCertificate(m_certificates.first());
|
static_cast<QSslSocket *>(serverSocket)->setLocalCertificate(m_certificates.first());
|
||||||
#endif
|
#endif
|
||||||
static_cast<QSslSocket *>(serverSocket)->setPeerVerifyMode(QSslSocket::VerifyNone);
|
|
||||||
static_cast<QSslSocket *>(serverSocket)->startServerEncryption();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
new Connection(serverSocket, m_requestHandler, this);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
serverSocket->deleteLater();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef QT_NO_OPENSSL
|
|
||||||
QList<QSslCipher> Server::safeCipherList() const
|
QList<QSslCipher> Server::safeCipherList() const
|
||||||
{
|
{
|
||||||
const QStringList badCiphers = {"idea", "rc4"};
|
const QStringList badCiphers = {"idea", "rc4"};
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#define HTTP_SERVER_H
|
#define HTTP_SERVER_H
|
||||||
|
|
||||||
#include <QTcpServer>
|
#include <QTcpServer>
|
||||||
|
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
#include <QSslCertificate>
|
#include <QSslCertificate>
|
||||||
#include <QSslCipher>
|
#include <QSslCipher>
|
||||||
@@ -60,14 +61,14 @@ namespace Http
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IRequestHandler *m_requestHandler;
|
|
||||||
|
|
||||||
#ifdef QBT_USES_QT5
|
#ifdef QBT_USES_QT5
|
||||||
void incomingConnection(qintptr socketDescriptor);
|
void incomingConnection(qintptr socketDescriptor);
|
||||||
#else
|
#else
|
||||||
void incomingConnection(int socketDescriptor);
|
void incomingConnection(int socketDescriptor);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
IRequestHandler *m_requestHandler;
|
||||||
|
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
QList<QSslCipher> safeCipherList() const;
|
QList<QSslCipher> safeCipherList() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user