From 0cd8309240cd48fdc16d9cc433297e33a0a2cdd0 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 11 Dec 2022 18:26:02 +0200 Subject: [PATCH] Fix processing of IPv6 addresses in HTTP server --- source/http/server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/http/server.cpp b/source/http/server.cpp index 9c9a876..04bae0b 100644 --- a/source/http/server.cpp +++ b/source/http/server.cpp @@ -146,7 +146,7 @@ void Server::client_data_available(Client &cl) cl.request = make_unique(Request::parse(cl.in_buf)); string addr_str = cl.sock->get_peer_address().str(); - string::size_type colon = addr_str.find(':'); + string::size_type colon = addr_str.find(':', (addr_str[0]=='[' ? addr_str.find(']')+1 : 0)); cl.request->set_header("-Client-Host", addr_str.substr(0, colon)); if(cl.request->get_method()!="GET" && cl.request->get_method()!="POST") -- 2.43.0