Fix resolving of IPv6 addresses

v2: move the check from Cluster to DNSResolver
This commit is contained in:
Azat Khuzhin 2021-05-20 08:13:17 +03:00
parent 89d4d0d5e6
commit 0536db0ec3
3 changed files with 22 additions and 3 deletions

View File

@ -87,9 +87,20 @@ static DNSResolver::IPAddresses resolveIPAddressImpl(const std::string & host)
{ {
Poco::Net::IPAddress ip; Poco::Net::IPAddress ip;
/// NOTE: Poco::Net::DNS::resolveOne(host) doesn't work for IP addresses like 127.0.0.2 /// NOTE:
if (Poco::Net::IPAddress::tryParse(host, ip)) /// - Poco::Net::DNS::resolveOne(host) doesn't work for IP addresses like 127.0.0.2
return DNSResolver::IPAddresses(1, ip); /// - Poco::Net::IPAddress::tryParse() expect hex string for IPv6 (w/o brackets)
if (host.starts_with('['))
{
assert(host.ends_with(']'));
if (Poco::Net::IPAddress::tryParse(host.substr(1, host.size() - 2), ip))
return DNSResolver::IPAddresses(1, ip);
}
else
{
if (Poco::Net::IPAddress::tryParse(host, ip))
return DNSResolver::IPAddresses(1, ip);
}
/// Family: AF_UNSPEC /// Family: AF_UNSPEC
/// AI_ALL is required for checking if client is allowed to connect from an address /// AI_ALL is required for checking if client is allowed to connect from an address

View File

@ -0,0 +1,8 @@
SET connections_with_failover_max_tries=0;
SELECT * FROM remote('[::1]', system.one) FORMAT Null;
SELECT * FROM remote('[::1]:9000', system.one) FORMAT Null;
SELECT * FROM remote('[::1', system.one) FORMAT Null; -- { serverError 36 }
SELECT * FROM remote('::1]', system.one) FORMAT Null; -- { serverError 519 }
SELECT * FROM remote('::1', system.one) FORMAT Null; -- { serverError 519 }