mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 10:02:01 +00:00
Merge branch 'secure_password' of https://github.com/millb/ClickHouse into secure_password
This commit is contained in:
commit
43d4838849
@ -139,8 +139,7 @@ String Cluster::Address::toFullString() const
|
||||
{
|
||||
return
|
||||
((shard_index == 0) ? "" : "shard" + std::to_string(shard_index)) +
|
||||
((replica_index == 0) ? "" : "_replica" + std::to_string(replica_index)) +
|
||||
((secure == Protocol::Secure::Enable) ? "+secure" : "");
|
||||
((replica_index == 0) ? "" : "_replica" + std::to_string(replica_index));
|
||||
}
|
||||
|
||||
Cluster::Address Cluster::Address::fromFullString(const String & full_string)
|
||||
@ -148,17 +147,9 @@ Cluster::Address Cluster::Address::fromFullString(const String & full_string)
|
||||
const char * address_begin = full_string.data();
|
||||
const char * address_end = address_begin + full_string.size();
|
||||
|
||||
Protocol::Secure secure = Protocol::Secure::Disable;
|
||||
const char * secure_tag = "+secure";
|
||||
if (endsWith(full_string, secure_tag))
|
||||
{
|
||||
address_end -= strlen(secure_tag);
|
||||
secure = Protocol::Secure::Enable;
|
||||
}
|
||||
|
||||
const char * user_pw_end = strchr(full_string.data(), '@');
|
||||
|
||||
/// parsing with format [shard{shard_index}[_replica{replica_index}]]
|
||||
/// parsing with [shard{shard_index}[_replica{replica_index}]] format
|
||||
if (!user_pw_end && startsWith(full_string, "shard"))
|
||||
{
|
||||
const char * underscore = strchr(full_string.data(), '_');
|
||||
@ -169,6 +160,15 @@ Cluster::Address Cluster::Address::fromFullString(const String & full_string)
|
||||
return address;
|
||||
}
|
||||
|
||||
/// parsing with old user[:password]@host:port#default_database format
|
||||
Protocol::Secure secure = Protocol::Secure::Disable;
|
||||
const char * secure_tag = "+secure";
|
||||
if (endsWith(full_string, secure_tag))
|
||||
{
|
||||
address_end -= strlen(secure_tag);
|
||||
secure = Protocol::Secure::Enable;
|
||||
}
|
||||
|
||||
const char * colon = strchr(full_string.data(), ':');
|
||||
if (!user_pw_end || !colon)
|
||||
throw Exception("Incorrect user[:password]@host:port#default_database format " + full_string, ErrorCodes::SYNTAX_ERROR);
|
||||
|
Loading…
Reference in New Issue
Block a user