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);