Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
48088156
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
48088156
编写于
2月 16, 2020
作者:
A
alexey-milovidov
提交者:
GitHub
2月 16, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Slightly more readable.
上级
6916caf7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
29 deletion
+36
-29
dbms/src/Interpreters/Cluster.cpp
dbms/src/Interpreters/Cluster.cpp
+36
-29
未找到文件。
dbms/src/Interpreters/Cluster.cpp
浏览文件 @
48088156
...
...
@@ -149,7 +149,7 @@ Cluster::Address Cluster::Address::fromFullString(const String & full_string)
const
char
*
user_pw_end
=
strchr
(
full_string
.
data
(),
'@'
);
/// parsing with [shard{shard_index}[_replica{replica_index}]] format
/// parsing with
the new
[shard{shard_index}[_replica{replica_index}]] format
if
(
!
user_pw_end
&&
startsWith
(
full_string
,
"shard"
))
{
const
char
*
underscore
=
strchr
(
full_string
.
data
(),
'_'
);
...
...
@@ -157,38 +157,45 @@ Cluster::Address Cluster::Address::fromFullString(const String & full_string)
Address
address
;
address
.
shard_index
=
parse
<
UInt32
>
(
address_begin
+
5
);
address
.
replica_index
=
underscore
?
parse
<
UInt32
>
(
underscore
+
8
)
:
0
;
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
))
else
{
address_end
-=
strlen
(
secure_tag
);
secure
=
Protocol
::
Secure
::
Enable
;
}
/// parsing with the old user[:password]@host:port#default_database format
/// This format is appeared to be inconvenient for the following reasons:
/// - credentials are exposed in file name;
/// - the file name can be too long.
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
);
const
bool
has_pw
=
colon
<
user_pw_end
;
const
char
*
host_end
=
has_pw
?
strchr
(
user_pw_end
+
1
,
':'
)
:
colon
;
if
(
!
host_end
)
throw
Exception
(
"Incorrect address '"
+
full_string
+
"', it does not contain port"
,
ErrorCodes
::
SYNTAX_ERROR
);
const
char
*
has_db
=
strchr
(
full_string
.
data
(),
'#'
);
const
char
*
port_end
=
has_db
?
has_db
:
address_end
;
Address
address
;
address
.
secure
=
secure
;
address
.
port
=
parse
<
UInt16
>
(
host_end
+
1
,
port_end
-
(
host_end
+
1
));
address
.
host_name
=
unescapeForFileName
(
std
::
string
(
user_pw_end
+
1
,
host_end
));
address
.
user
=
unescapeForFileName
(
std
::
string
(
address_begin
,
has_pw
?
colon
:
user_pw_end
));
address
.
password
=
has_pw
?
unescapeForFileName
(
std
::
string
(
colon
+
1
,
user_pw_end
))
:
std
::
string
();
address
.
default_database
=
has_db
?
unescapeForFileName
(
std
::
string
(
has_db
+
1
,
address_end
))
:
std
::
string
();
return
address
;
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
);
const
bool
has_pw
=
colon
<
user_pw_end
;
const
char
*
host_end
=
has_pw
?
strchr
(
user_pw_end
+
1
,
':'
)
:
colon
;
if
(
!
host_end
)
throw
Exception
(
"Incorrect address '"
+
full_string
+
"', it does not contain port"
,
ErrorCodes
::
SYNTAX_ERROR
);
const
char
*
has_db
=
strchr
(
full_string
.
data
(),
'#'
);
const
char
*
port_end
=
has_db
?
has_db
:
address_end
;
Address
address
;
address
.
secure
=
secure
;
address
.
port
=
parse
<
UInt16
>
(
host_end
+
1
,
port_end
-
(
host_end
+
1
));
address
.
host_name
=
unescapeForFileName
(
std
::
string
(
user_pw_end
+
1
,
host_end
));
address
.
user
=
unescapeForFileName
(
std
::
string
(
address_begin
,
has_pw
?
colon
:
user_pw_end
));
address
.
password
=
has_pw
?
unescapeForFileName
(
std
::
string
(
colon
+
1
,
user_pw_end
))
:
std
::
string
();
address
.
default_database
=
has_db
?
unescapeForFileName
(
std
::
string
(
has_db
+
1
,
address_end
))
:
std
::
string
();
return
address
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录