diff options
Diffstat (limited to 'src/zenhttp/servers')
| -rw-r--r-- | src/zenhttp/servers/httpasio.cpp | 28 | ||||
| -rw-r--r-- | src/zenhttp/servers/httpsys.cpp | 17 |
2 files changed, 43 insertions, 2 deletions
diff --git a/src/zenhttp/servers/httpasio.cpp b/src/zenhttp/servers/httpasio.cpp index a2cae8762..7972777b8 100644 --- a/src/zenhttp/servers/httpasio.cpp +++ b/src/zenhttp/servers/httpasio.cpp @@ -1330,14 +1330,36 @@ HttpServerConnectionT<SocketType>::HandleRequest() { auto RemoteEndpoint = m_Socket->remote_endpoint(); IsLocalConnection = m_Socket->local_endpoint().address() == RemoteEndpoint.address(); - RemoteAddress = RemoteEndpoint.address().to_string(); + auto Addr = RemoteEndpoint.address(); + RemoteAddress = Addr.to_string(); + if (Addr.is_v4()) + { + auto Bytes = Addr.to_v4().to_bytes(); + m_Server.m_HttpServer->MarkClientAddress(Bytes.data(), Bytes.size()); + } + else + { + auto Bytes = Addr.to_v6().to_bytes(); + m_Server.m_HttpServer->MarkClientAddress(Bytes.data(), Bytes.size()); + } } #if ZEN_USE_OPENSSL else if constexpr (std::is_same_v<SocketType, SslSocket>) { auto RemoteEndpoint = m_Socket->lowest_layer().remote_endpoint(); IsLocalConnection = m_Socket->lowest_layer().local_endpoint().address() == RemoteEndpoint.address(); - RemoteAddress = RemoteEndpoint.address().to_string(); + auto Addr = RemoteEndpoint.address(); + RemoteAddress = Addr.to_string(); + if (Addr.is_v4()) + { + auto Bytes = Addr.to_v4().to_bytes(); + m_Server.m_HttpServer->MarkClientAddress(Bytes.data(), Bytes.size()); + } + else + { + auto Bytes = Addr.to_v6().to_bytes(); + m_Server.m_HttpServer->MarkClientAddress(Bytes.data(), Bytes.size()); + } } #endif else @@ -1345,6 +1367,8 @@ HttpServerConnectionT<SocketType>::HandleRequest() RemoteAddress = "unix"; } + m_Server.m_HttpServer->MarkSessionId(m_RequestData.SessionId()); + HttpAsioServerRequest Request(m_RequestData, *Service, m_RequestData.Body(), diff --git a/src/zenhttp/servers/httpsys.cpp b/src/zenhttp/servers/httpsys.cpp index 9fe9a2254..2cad97725 100644 --- a/src/zenhttp/servers/httpsys.cpp +++ b/src/zenhttp/servers/httpsys.cpp @@ -2020,6 +2020,23 @@ HttpSysTransaction::InvokeRequestHandler(HttpService& Service, IoBuffer Payload) m_HttpServer.MarkRequest(); + // Track distinct client addresses + { + const SOCKADDR* SockAddr = HttpRequest()->Address.pRemoteAddress; + if (SockAddr->sa_family == AF_INET) + { + const SOCKADDR_IN* V4 = reinterpret_cast<const SOCKADDR_IN*>(SockAddr); + m_HttpServer.MarkClientAddress(&V4->sin_addr, sizeof(V4->sin_addr)); + } + else if (SockAddr->sa_family == AF_INET6) + { + const SOCKADDR_IN6* V6 = reinterpret_cast<const SOCKADDR_IN6*>(SockAddr); + m_HttpServer.MarkClientAddress(&V6->sin6_addr, sizeof(V6->sin6_addr)); + } + } + + m_HttpServer.MarkSessionId(ThisRequest.SessionId()); + // Default request handling # if ZEN_WITH_OTEL |