Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
joec3
TDengine
提交
44e4b59e
TDengine
项目概览
joec3
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
44e4b59e
编写于
5月 28, 2020
作者:
T
Tao Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-424] puhua security test develop: ip whitelist
上级
f9aef575
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
82 addition
and
4 deletion
+82
-4
src/inc/taoserror.h
src/inc/taoserror.h
+2
-1
src/inc/tglobalcfg.h
src/inc/tglobalcfg.h
+2
-1
src/inc/tsdb.h
src/inc/tsdb.h
+1
-0
src/rpc/src/trpc.c
src/rpc/src/trpc.c
+17
-1
src/rpc/src/tstring.c
src/rpc/src/tstring.c
+1
-0
src/util/src/tglobalcfg.c
src/util/src/tglobalcfg.c
+59
-1
未找到文件。
src/inc/taoserror.h
浏览文件 @
44e4b59e
...
...
@@ -139,8 +139,9 @@ extern "C" {
#define TSDB_CODE_TABLE_ID_MISMATCH 118
#define TSDB_CODE_QUERY_CACHE_ERASED 119
#define TSDB_CODE_AUTH_BANNED_PERIOD 120
#define TSDB_CODE_IP_WHITELIST_FILTERED 121
#define TSDB_CODE_MAX_ERROR_CODE 12
1
#define TSDB_CODE_MAX_ERROR_CODE 12
2
#ifdef __cplusplus
}
...
...
src/inc/tglobalcfg.h
浏览文件 @
44e4b59e
...
...
@@ -55,6 +55,7 @@ extern char dataDir[];
extern
char
logDir
[];
extern
char
scriptDir
[];
extern
char
osName
[];
extern
int32_t
tsWhiteListIps
[];
extern
char
tsMasterIp
[];
extern
char
tsSecondIp
[];
...
...
@@ -256,7 +257,7 @@ extern int tsGlobalConfigNum;
extern
char
*
tsCfgStatusStr
[];
SGlobalConfig
*
tsGetConfigOption
(
const
char
*
option
);
#define TSDB_CFG_MAX_NUM 11
1
#define TSDB_CFG_MAX_NUM 11
2
#define TSDB_CFG_PRINT_LEN 23
#define TSDB_CFG_OPTION_LEN 24
#define TSDB_CFG_VALUE_LEN 41
...
...
src/inc/tsdb.h
浏览文件 @
44e4b59e
...
...
@@ -211,6 +211,7 @@ extern "C" {
#define TSDB_DATA_NULL_STR_L "null"
#define TSDB_MAX_RPC_THREADS 5
#define TSDB_MAX_IP_WHITELIST 10
#define TSDB_QUERY_TYPE_NON_TYPE 0x00U // none type
#define TSDB_QUERY_TYPE_FREE_RESOURCE 0x01U // free qhandle at vnode
...
...
src/rpc/src/trpc.c
浏览文件 @
44e4b59e
...
...
@@ -812,6 +812,16 @@ void taosProcessResponse(SRpcConn *pConn) {
}
int
taosCheckIPinWhiteList
(
int32_t
ip
)
{
for
(
int
i
=
0
;
i
<
TSDB_MAX_IP_WHITELIST
;
i
++
)
{
if
((
tsWhiteListIps
[
i
]
!=
0
)
&&
(
ip
&
tsWhiteListIps
[
i
])
==
tsWhiteListIps
[
i
])
return
0
;
}
return
TSDB_CODE_IP_WHITELIST_FILTERED
;
}
int
taosProcessMsgHeader
(
STaosHeader
*
pHeader
,
SRpcConn
**
ppConn
,
STaosRpc
*
pServer
,
int
dataLen
,
uint32_t
ip
,
uint16_t
port
,
void
*
chandle
)
{
int
chann
,
sid
,
code
=
0
;
...
...
@@ -825,7 +835,13 @@ int taosProcessMsgHeader(STaosHeader *pHeader, SRpcConn **ppConn, STaosRpc *pSer
uint32_t
destId
=
htonl
(
pHeader
->
destId
);
chann
=
destId
>>
pServer
->
bits
;
sid
=
destId
&
pServer
->
mask
;
if
(
tscEmbedded
){
code
=
taosCheckIPinWhiteList
(
ip
);
if
(
code
)
{
tError
(
"%s cid:%d sid:%d, ip not in whitelist"
,
pServer
->
label
,
chann
,
sid
);
return
code
;
}
}
if
(
pHeader
->
msgType
>=
TSDB_MSG_TYPE_MAX
||
pHeader
->
msgType
<=
0
)
{
tTrace
(
"%s cid:%d sid:%d, invalid message type:%d"
,
pServer
->
label
,
chann
,
sid
,
pHeader
->
msgType
);
return
TSDB_CODE_INVALID_MSG_TYPE
;
...
...
src/rpc/src/tstring.c
浏览文件 @
44e4b59e
...
...
@@ -245,4 +245,5 @@ char *tsError[] = {"success",
"table id/uid mismatch"
,
"client query cache erased"
,
// 119
"too many authentication failed, try 10 minutes later"
,
//120
"ip not in white list , connection denied"
,
//121
};
src/util/src/tglobalcfg.c
浏览文件 @
44e4b59e
...
...
@@ -123,6 +123,8 @@ char tsDefaultPass[64] = DB_COMPANY;
int
tsMaxMeterConnections
=
10000
;
int
tsMaxMgmtConnections
=
2000
;
int
tsMaxVnodeConnections
=
10000
;
int32_t
tsWhiteListIps
[
TSDB_MAX_IP_WHITELIST
]
=
{
0
};
char
tsWhiteListIp
[
TSDB_IPv4ADDR_LEN
]
=
{
0
};
int
tsBalanceMonitorInterval
=
2
;
// seconds
int
tsBalanceStartInterval
=
300
;
// seconds
...
...
@@ -484,6 +486,9 @@ static void doInitGlobalConfig() {
tsInitConfigOption
(
cfg
++
,
"httpIp"
,
tsHttpIp
,
TSDB_CFG_VTYPE_IPSTR
,
TSDB_CFG_CTYPE_B_CONFIG
,
0
,
0
,
TSDB_IPv4ADDR_LEN
,
TSDB_CFG_UTYPE_NONE
);
tsInitConfigOption
(
cfg
++
,
"ipWhiteList"
,
tsWhiteListIp
,
TSDB_CFG_VTYPE_IPSTR
,
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_CLIENT
,
0
,
0
,
TSDB_IPv4ADDR_LEN
,
TSDB_CFG_UTYPE_NONE
);
// port
tsInitConfigOption
(
cfg
++
,
"httpPort"
,
&
tsHttpPort
,
TSDB_CFG_VTYPE_SHORT
,
...
...
@@ -1212,7 +1217,60 @@ void tsSetTimeZone() {
#ifndef CLUSTER
bool
tsReadGlobalConfigSpec
()
{
return
true
;
}
bool
tsReadGlobalConfigSpec
()
{
FILE
*
fp
;
char
*
line
,
*
option
,
*
value
,
*
value1
;
size_t
len
;
int
olen
,
vlen
,
vlen1
;
int
netmask
;
int
i
=
0
;
char
fileName
[
128
];
sprintf
(
fileName
,
"%s/%s.cfg"
,
configDir
,
DB_CLIENT_NAME
);
fp
=
fopen
(
fileName
,
"r"
);
if
(
fp
==
NULL
)
{
}
else
{
line
=
NULL
;
while
(
!
feof
(
fp
))
{
tfree
(
line
);
line
=
option
=
value
=
NULL
;
len
=
olen
=
vlen
=
0
;
getline
(
&
line
,
&
len
,
fp
);
if
(
line
==
NULL
)
break
;
paGetToken
(
line
,
&
option
,
&
olen
);
if
(
olen
==
0
)
continue
;
option
[
olen
]
=
0
;
paGetToken
(
option
+
olen
+
1
,
&
value
,
&
vlen
);
if
(
vlen
==
0
)
continue
;
value
[
vlen
]
=
0
;
// For dataDir, the format is:
// dataDir /mnt/disk1 0
paGetToken
(
value
+
vlen
+
1
,
&
value1
,
&
vlen1
);
if
(
strncasecmp
(
option
,
"ipWhiteList"
,
11
)
==
0
)
{
if
(
!
tscEmbedded
||
i
>=
TSDB_MAX_IP_WHITELIST
)
continue
;
if
(
vlen1
==
0
)
{
netmask
=
32
;
}
else
{
netmask
=
(
int
)
atoi
(
value1
);
if
(
netmask
>
32
)
netmask
=
32
;
}
int
ipInt
=
inet_addr
(
value
);
tsWhiteListIps
[
i
]
=
ipInt
&
(
0xFFFFFFFF
>>
(
32
-
netmask
));
i
++
;
}
}
tfree
(
line
);
fclose
(
fp
);
}
return
true
;
}
void
tsPrintGlobalConfigSpec
()
{
pPrint
(
" dataDir: %s"
,
dataDir
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录