diff options
Diffstat (limited to 'src/zenhttp/servers/httpsys.cpp')
| -rw-r--r-- | src/zenhttp/servers/httpsys.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/zenhttp/servers/httpsys.cpp b/src/zenhttp/servers/httpsys.cpp index 9fe9a2254..1b722940d 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 @@ -2578,7 +2595,14 @@ InitialRequestHandler::HandleCompletion(ULONG IoResult, ULONG_PTR NumberOfBytesT &Transaction().Server())); Ref<WebSocketConnection> WsConnRef(WsConn.Get()); - WsHandler->OnWebSocketOpen(std::move(WsConnRef)); + ExtendableStringBuilder<128> UrlUtf8; + WideToUtf8({(wchar_t*)HttpReq->CookedUrl.pAbsPath, + gsl::narrow<size_t>(HttpReq->CookedUrl.AbsPathLength / sizeof(wchar_t))}, + UrlUtf8); + int PrefixLen = Service->UriPrefixLength(); + std::string_view RelativeUri{UrlUtf8.ToView()}; + RelativeUri.remove_prefix(std::min(PrefixLen, static_cast<int>(RelativeUri.size()))); + WsHandler->OnWebSocketOpen(std::move(WsConnRef), RelativeUri); WsConn->Start(); return nullptr; |