From a2c769f17334307a4d84272dbafdc2f1cb8f56f4 Mon Sep 17 00:00:00 2001 From: Salanto <62221668+Salanto@users.noreply.github.com> Date: Thu, 9 Jun 2022 20:49:37 +0200 Subject: [PATCH] Finish desturctor, fix localhost lookup --- core/include/network/network_socket.h | 5 +++++ core/src/network/network_socket.cpp | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/core/include/network/network_socket.h b/core/include/network/network_socket.h index 8f9e383..1b7213f 100644 --- a/core/include/network/network_socket.h +++ b/core/include/network/network_socket.h @@ -44,6 +44,11 @@ class NetworkSocket : public QObject */ NetworkSocket(QWebSocket *f_socket, QObject *parent = nullptr); + /** + * @brief Default destructor for the NetworkSocket object. + */ + ~NetworkSocket(); + /** * @brief Returns the Address of the remote socket. * diff --git a/core/src/network/network_socket.cpp b/core/src/network/network_socket.cpp index e19391c..bf23521 100644 --- a/core/src/network/network_socket.cpp +++ b/core/src/network/network_socket.cpp @@ -39,7 +39,8 @@ NetworkSocket::NetworkSocket(QWebSocket *f_socket, QObject *parent) : this, &NetworkSocket::clientDisconnected); bool l_is_local = (m_client_socket.ws->peerAddress() == QHostAddress::LocalHost) || - (m_client_socket.ws->peerAddress() == QHostAddress::LocalHostIPv6); + (m_client_socket.ws->peerAddress() == QHostAddress::LocalHostIPv6) || + (m_client_socket.ws->peerAddress() == QHostAddress("::ffff:127.0.0.1")); // TLDR : We check if the header comes trough a proxy/tunnel running locally. // This is to ensure nobody can send those headers from the web. QNetworkRequest l_request = m_client_socket.ws->request(); @@ -51,6 +52,16 @@ NetworkSocket::NetworkSocket(QWebSocket *f_socket, QObject *parent) : } } +NetworkSocket::~NetworkSocket() +{ + if (m_socket_type == TCP) { + m_client_socket.tcp->deleteLater(); + } + else { + m_client_socket.ws->deleteLater(); + } +} + QHostAddress NetworkSocket::peerAddress() { return m_socket_ip;