mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
Merge pull request #6661 from Icinga/bugfix/cache-http-peer-address
Cache the peer address in the HTTP server
This commit is contained in:
commit
e6eb703b36
@ -47,6 +47,17 @@ HttpServerConnection::HttpServerConnection(const String& identity, bool authenti
|
|||||||
|
|
||||||
if (authenticated)
|
if (authenticated)
|
||||||
m_ApiUser = ApiUser::GetByClientCN(identity);
|
m_ApiUser = ApiUser::GetByClientCN(identity);
|
||||||
|
|
||||||
|
/* Cache the peer address. */
|
||||||
|
m_PeerAddress = "<unknown>";
|
||||||
|
|
||||||
|
if (stream) {
|
||||||
|
Socket::Ptr socket = m_Stream->GetSocket();
|
||||||
|
|
||||||
|
if (socket) {
|
||||||
|
m_PeerAddress = socket->GetPeerAddress();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpServerConnection::StaticInitialize()
|
void HttpServerConnection::StaticInitialize()
|
||||||
@ -84,7 +95,7 @@ void HttpServerConnection::Disconnect()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Log(LogInformation, "HttpServerConnection")
|
Log(LogInformation, "HttpServerConnection")
|
||||||
<< "HTTP client disconnected (from " << m_Stream->GetSocket()->GetPeerAddress() << ")";
|
<< "HTTP client disconnected (from " << m_PeerAddress << ")";
|
||||||
|
|
||||||
ApiListener::Ptr listener = ApiListener::GetInstance();
|
ApiListener::Ptr listener = ApiListener::GetInstance();
|
||||||
listener->RemoveHttpClient(this);
|
listener->RemoveHttpClient(this);
|
||||||
@ -201,11 +212,9 @@ bool HttpServerConnection::ManageHeaders(HttpResponse& response)
|
|||||||
|
|
||||||
String requestUrl = m_CurrentRequest.RequestUrl->Format();
|
String requestUrl = m_CurrentRequest.RequestUrl->Format();
|
||||||
|
|
||||||
Socket::Ptr socket = m_Stream->GetSocket();
|
|
||||||
|
|
||||||
Log(LogInformation, "HttpServerConnection")
|
Log(LogInformation, "HttpServerConnection")
|
||||||
<< "Request: " << m_CurrentRequest.RequestMethod << " " << requestUrl
|
<< "Request: " << m_CurrentRequest.RequestMethod << " " << requestUrl
|
||||||
<< " (from " << (socket ? socket->GetPeerAddress() : "<unkown>")
|
<< " (from " << m_PeerAddress << ")"
|
||||||
<< ", user: " << (m_AuthenticatedUser ? m_AuthenticatedUser->GetName() : "<unauthenticated>") << ")";
|
<< ", user: " << (m_AuthenticatedUser ? m_AuthenticatedUser->GetName() : "<unauthenticated>") << ")";
|
||||||
|
|
||||||
ApiListener::Ptr listener = ApiListener::GetInstance();
|
ApiListener::Ptr listener = ApiListener::GetInstance();
|
||||||
|
@ -59,6 +59,7 @@ private:
|
|||||||
boost::recursive_mutex m_DataHandlerMutex;
|
boost::recursive_mutex m_DataHandlerMutex;
|
||||||
WorkQueue m_RequestQueue;
|
WorkQueue m_RequestQueue;
|
||||||
int m_PendingRequests;
|
int m_PendingRequests;
|
||||||
|
String m_PeerAddress;
|
||||||
|
|
||||||
StreamReadContext m_Context;
|
StreamReadContext m_Context;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user