diff options
| author | bulatman <[email protected]> | 2024-11-01 02:33:12 +0300 |
|---|---|---|
| committer | bulatman <[email protected]> | 2024-11-01 02:43:09 +0300 |
| commit | 5382ca1e2aeacc5deeb51470980ea2fe67ba4944 (patch) | |
| tree | c0275806700114cefa83340d31782aca3bf473d6 | |
| parent | 17b966eafe95f4eeb58f79fd07a0237dd06df05d (diff) | |
YT: Use FormatNetworkAddress to build address from IP
commit_hash:56e50f44274025f97877254c8ec020c4a425be68
| -rw-r--r-- | yt/yt/core/http/helpers.cpp | 7 |
1 files 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 <yt/yt/core/json/json_parser.h> #include <yt/yt/core/json/config.h> +#include <yt/yt/core/net/address.h> + #include <yt/yt/core/ytree/fluent.h> #include <util/stream/buffer.h> @@ -308,8 +310,9 @@ std::optional<TString> 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 {}; |
