Finish desturctor, fix localhost lookup
This commit is contained in:
parent
a47e120ff4
commit
a2c769f173
@ -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.
|
||||
*
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user