algo ngigers
This commit is contained in:
parent
04c8829732
commit
0a0bd116d5
@ -45,7 +45,7 @@ int main(int argc, char *argv[])
|
|||||||
QCoreApplication::quit();
|
QCoreApplication::quit();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
server = new Server(ConfigManager::serverPort(), &app);
|
server = new Server(ConfigManager::serverPort(), ConfigManager::securePort(), &app);
|
||||||
server->start();
|
server->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,11 +12,13 @@
|
|||||||
#include "packet/packet_factory.h"
|
#include "packet/packet_factory.h"
|
||||||
#include "serverpublisher.h"
|
#include "serverpublisher.h"
|
||||||
|
|
||||||
Server::Server(int p_ws_port, QObject *parent) :
|
Server::Server(int p_ws_port, int p_wss_port, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_port(p_ws_port),
|
m_port(p_ws_port),
|
||||||
|
m_secure_port(p_wss_port),
|
||||||
m_player_count(0)
|
m_player_count(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
timer = new QTimer(this);
|
timer = new QTimer(this);
|
||||||
|
|
||||||
db_manager = new DBManager;
|
db_manager = new DBManager;
|
||||||
@ -38,6 +40,7 @@ void Server::start()
|
|||||||
{
|
{
|
||||||
QString bind_ip = ConfigManager::bindIP();
|
QString bind_ip = ConfigManager::bindIP();
|
||||||
QHostAddress bind_addr;
|
QHostAddress bind_addr;
|
||||||
|
|
||||||
if (bind_ip == "all")
|
if (bind_ip == "all")
|
||||||
bind_addr = QHostAddress::Any;
|
bind_addr = QHostAddress::Any;
|
||||||
else
|
else
|
||||||
@ -46,7 +49,15 @@ void Server::start()
|
|||||||
qDebug() << bind_ip << "is an invalid IP address to listen on! Server not starting, check your config.";
|
qDebug() << bind_ip << "is an invalid IP address to listen on! Server not starting, check your config.";
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile keyFile("/home/gor/Desktop/akashi-esquizolandia/bin/config/certs/private.key");
|
QSettings settings("config/ssl.ini", QSettings::IniFormat);
|
||||||
|
|
||||||
|
QString privateKeyPath = settings.value("SSL/privateKey").toString();
|
||||||
|
QString certificatePath = settings.value("SSL/certificate").toString();
|
||||||
|
QString caCertificatePath = settings.value("SSL/caCertificate").toString();
|
||||||
|
|
||||||
|
QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();
|
||||||
|
|
||||||
|
QFile keyFile(privateKeyPath);
|
||||||
if (!keyFile.open(QIODevice::ReadOnly)) {
|
if (!keyFile.open(QIODevice::ReadOnly)) {
|
||||||
qWarning() << "Unable to open private key file.";
|
qWarning() << "Unable to open private key file.";
|
||||||
return;
|
return;
|
||||||
@ -54,15 +65,23 @@ void Server::start()
|
|||||||
QSslKey privateKey(&keyFile, QSsl::Rsa);
|
QSslKey privateKey(&keyFile, QSsl::Rsa);
|
||||||
keyFile.close();
|
keyFile.close();
|
||||||
|
|
||||||
QFile certFile("/home/gor/Desktop/akashi-esquizolandia/bin/config/certs/certificate.crt");
|
QFile certFile(certificatePath);
|
||||||
if (!certFile.open(QIODevice::ReadOnly)) {
|
if (!certFile.open(QIODevice::ReadOnly)) {
|
||||||
qWarning() << "Unable to open certificate file.";
|
qWarning() << "Unable to open certificate file.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSslCertificate certificate(&certFile);
|
QSslCertificate certificate(&certFile);
|
||||||
certFile.close();
|
certFile.close();
|
||||||
|
|
||||||
QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();
|
|
||||||
|
QFile caFile(caCertificatePath);
|
||||||
|
if (caFile.open(QIODevice::ReadOnly)) {
|
||||||
|
QSslCertificate caCertificate(&caFile);
|
||||||
|
sslConfig.addCaCertificate(caCertificate);
|
||||||
|
caFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
sslConfig.setPrivateKey(privateKey);
|
sslConfig.setPrivateKey(privateKey);
|
||||||
sslConfig.setLocalCertificate(certificate);
|
sslConfig.setLocalCertificate(certificate);
|
||||||
|
|
||||||
|
@ -55,9 +55,10 @@ class Server : public QObject
|
|||||||
* @brief Creates a Server instance.
|
* @brief Creates a Server instance.
|
||||||
*
|
*
|
||||||
* @param p_ws_port The port to listen for connections on.
|
* @param p_ws_port The port to listen for connections on.
|
||||||
|
@param p_wss_port
|
||||||
* @param parent Qt-based parent, passed along to inherited constructor from QObject.
|
* @param parent Qt-based parent, passed along to inherited constructor from QObject.
|
||||||
*/
|
*/
|
||||||
Server(int p_ws_port, QObject *parent = nullptr);
|
Server(int p_ws_port, int p_wss_port, QObject *parent = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destructor for the Server class.
|
* @brief Destructor for the Server class.
|
||||||
@ -427,6 +428,7 @@ class Server : public QObject
|
|||||||
* @brief The port through which the server will accept WebSocket connections.
|
* @brief The port through which the server will accept WebSocket connections.
|
||||||
*/
|
*/
|
||||||
int m_port;
|
int m_port;
|
||||||
|
int m_secure_port;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The collection of all currently connected clients.
|
* @brief The collection of all currently connected clients.
|
||||||
|
Loading…
Reference in New Issue
Block a user