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;