Implement HTTP host header filtering

This filtering is required to defend against DNS rebinding attack.
This commit is contained in:
Chocobo1 2017-07-02 18:23:10 +08:00 committed by sledgehammer999
parent 18651c8d01
commit 0532d546d7
No known key found for this signature in database
GPG key ID: 6E4A2D025B7CC9A2
10 changed files with 109 additions and 8 deletions

View file

@ -74,8 +74,8 @@ void Connection::read()
break;
case RequestParser::NoError:
Environment env;
env.clientAddress = m_socket->peerAddress();
const Environment env {m_socket->localAddress(), m_socket->localPort(), m_socket->peerAddress(), m_socket->peerPort()};
Response response = m_requestHandler->processRequest(request, env);
if (acceptsGzipEncoding(request.headers["accept-encoding"]))
response.headers[HEADER_CONTENT_ENCODING] = "gzip";