mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 07:01:59 +00:00
Fix resolving of IPv6 addresses
v2: move the check from Cluster to DNSResolver
This commit is contained in:
parent
89d4d0d5e6
commit
0536db0ec3
@ -87,9 +87,20 @@ static DNSResolver::IPAddresses resolveIPAddressImpl(const std::string & host)
|
||||
{
|
||||
Poco::Net::IPAddress ip;
|
||||
|
||||
/// NOTE: Poco::Net::DNS::resolveOne(host) doesn't work for IP addresses like 127.0.0.2
|
||||
if (Poco::Net::IPAddress::tryParse(host, ip))
|
||||
return DNSResolver::IPAddresses(1, ip);
|
||||
/// NOTE:
|
||||
/// - Poco::Net::DNS::resolveOne(host) doesn't work for IP addresses like 127.0.0.2
|
||||
/// - 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
|
||||
/// AI_ALL is required for checking if client is allowed to connect from an address
|
||||
|
8
tests/queries/0_stateless/01880_remote_ipv6.sql
Normal file
8
tests/queries/0_stateless/01880_remote_ipv6.sql
Normal 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 }
|
Loading…
Reference in New Issue
Block a user