From 464dd0522e5728e038fbf42daec6dd9d82ebd091 Mon Sep 17 00:00:00 2001 From: Volodymyr Yavdoshenko Date: Sat, 15 Mar 2025 10:23:13 +0200 Subject: [PATCH] fix: optional brackets were removed for ipv6 host (#4759) fixed: IPv6 replication issues #4622 --- helio | 2 +- src/server/protocol_client.cc | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/helio b/helio index 6e29a5af3..309cf5816 160000 --- a/helio +++ b/helio @@ -1 +1 @@ -Subproject commit 6e29a5af38cb9e99be37469a87c6faac7114f55b +Subproject commit 309cf5816cee5eb732f31311b73bcdb31f51d378 diff --git a/src/server/protocol_client.cc b/src/server/protocol_client.cc index 672d22905..f127c7c04 100644 --- a/src/server/protocol_client.cc +++ b/src/server/protocol_client.cc @@ -135,7 +135,17 @@ ProtocolClient::~ProtocolClient() { error_code ProtocolClient::ResolveHostDns() { char ip_addr[INET6_ADDRSTRLEN]; - auto ec = util::fb2::DnsResolve(server_context_.host, 0, ip_addr, ProactorBase::me()); + + // IPv6 address can be enclosed in square brackets. + // https://www.rfc-editor.org/rfc/rfc2732#section-2 + // We need to remove the brackets before resolving the DNS. + // Enclosed IPv6 addresses can't be resolved by the DNS resolver. + std::string host = server_context_.host; + if (!host.empty() && host.front() == '[' && host.back() == ']') { + host = host.substr(1, host.size() - 2); + } + + auto ec = util::fb2::DnsResolve(host, 0, ip_addr, ProactorBase::me()); if (ec) { LOG(ERROR) << "Dns error " << ec << ", host: " << server_context_.host; return make_error_code(errc::host_unreachable);