From 5382ca1e2aeacc5deeb51470980ea2fe67ba4944 Mon Sep 17 00:00:00 2001 From: bulatman Date: Fri, 1 Nov 2024 02:33:12 +0300 Subject: YT: Use FormatNetworkAddress to build address from IP commit_hash:56e50f44274025f97877254c8ec020c4a425be68 --- yt/yt/core/http/helpers.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/yt/yt/core/http/helpers.cpp b/yt/yt/core/http/helpers.cpp index e5bead9511b..5ed8355c6d4 100644 --- a/yt/yt/core/http/helpers.cpp +++ b/yt/yt/core/http/helpers.cpp @@ -12,6 +12,8 @@ #include #include +#include + #include #include @@ -308,8 +310,9 @@ std::optional FindBalancerRealIP(const IRequestPtr& req) auto forwardedFor = headers->Find(XForwardedForYHeaderName); auto sourcePort = headers->Find(XSourcePortYHeaderName); - if (forwardedFor && sourcePort) { - return Format("[%v]:%v", *forwardedFor, *sourcePort); + int port = 0; + if (forwardedFor && sourcePort && TryIntFromString<10>(*sourcePort, port)) { + return NNet::FormatNetworkAddress(*forwardedFor, port); } return {}; -- cgit v1.3