Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5049b99b
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
Fork
4786
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
5049b99b
编写于
3月 01, 2020
作者:
陶建辉(Jeff)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change the uid in RPC head to linkUid, hide user name once it is authenticated
上级
c3130c7f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
13 deletion
+13
-13
src/rpc/inc/rpcHead.h
src/rpc/inc/rpcHead.h
+1
-1
src/rpc/src/rpcMain.c
src/rpc/src/rpcMain.c
+12
-12
未找到文件。
src/rpc/inc/rpcHead.h
浏览文件 @
5049b99b
...
...
@@ -48,7 +48,7 @@ typedef struct {
char
spi
:
3
;
// security parameter index
char
encrypt
:
3
;
// encrypt algorithm, 0: no encryption
uint16_t
tranId
;
// transcation ID
uint32_t
uid
;
// for unique ID inside a
client
uint32_t
linkUid
;
// for unique connection ID assigned by
client
uint32_t
sourceId
;
// source ID, an index for connection list
uint32_t
destId
;
// destination ID, an index for connection list
uint32_t
destIp
;
// destination IP address, for NAT scenario
...
...
src/rpc/src/rpcMain.c
浏览文件 @
5049b99b
...
...
@@ -96,7 +96,7 @@ typedef struct _RpcConn {
char
ckey
[
TSDB_KEY_LEN
];
// ciphering key
char
secured
;
// if set to 1, no authentication
uint16_t
localPort
;
// for UDP only
uint32_t
peerUid
;
// peer UID
uint32_t
linkUid
;
// connection unique ID assigned by client
uint32_t
peerIp
;
// peer IP
uint32_t
destIp
;
// server destination IP to handle NAT
uint16_t
peerPort
;
// peer port
...
...
@@ -400,10 +400,9 @@ void rpcSendResponse(void *handle, int32_t code, void *pCont, int contLen) {
pHead
->
tranId
=
pConn
->
inTranId
;
pHead
->
sourceId
=
pConn
->
ownId
;
pHead
->
destId
=
pConn
->
peerId
;
pHead
->
uid
=
0
;
pHead
->
linkUid
=
pConn
->
linkUid
;
pHead
->
port
=
htons
(
pConn
->
localPort
);
pHead
->
code
=
htonl
(
code
);
memcpy
(
pHead
->
user
,
pConn
->
user
,
tListLen
(
pHead
->
user
));
// set pConn parameters
pConn
->
inType
=
0
;
...
...
@@ -499,7 +498,7 @@ static void rpcCloseConn(void *thandle) {
if
(
pRpc
->
connType
==
TAOS_CONN_SERVER
)
{
char
hashstr
[
40
]
=
{
0
};
sprintf
(
hashstr
,
"%x:%x:%x:%d"
,
pConn
->
peerIp
,
pConn
->
peer
Uid
,
pConn
->
peerId
,
pConn
->
connType
);
sprintf
(
hashstr
,
"%x:%x:%x:%d"
,
pConn
->
peerIp
,
pConn
->
link
Uid
,
pConn
->
peerId
,
pConn
->
connType
);
taosDeleteStrHash
(
pRpc
->
hash
,
hashstr
);
rpcFreeMsg
(
pConn
->
pRspMsg
);
// it may have a response msg saved, but not request msg
pConn
->
pRspMsg
=
NULL
;
...
...
@@ -535,6 +534,7 @@ static SRpcConn *rpcAllocateClientConn(SRpcInfo *pRpc) {
pConn
->
sid
=
sid
;
pConn
->
tranId
=
(
uint16_t
)(
rand
()
&
0xFFFF
);
pConn
->
ownId
=
htonl
(
pConn
->
sid
);
pConn
->
linkUid
=
(
uint32_t
)((
int64_t
)
pConn
+
(
int64_t
)
getpid
());
pConn
->
spi
=
pRpc
->
spi
;
pConn
->
encrypt
=
pRpc
->
encrypt
;
if
(
pConn
->
spi
)
memcpy
(
pConn
->
secret
,
pRpc
->
secret
,
TSDB_KEY_LEN
);
...
...
@@ -548,7 +548,7 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
char
hashstr
[
40
]
=
{
0
};
SRpcHead
*
pHead
=
(
SRpcHead
*
)
pRecv
->
msg
;
sprintf
(
hashstr
,
"%x:%x:%x:%d"
,
pRecv
->
ip
,
pHead
->
u
id
,
pHead
->
sourceId
,
pRecv
->
connType
);
sprintf
(
hashstr
,
"%x:%x:%x:%d"
,
pRecv
->
ip
,
pHead
->
linkU
id
,
pHead
->
sourceId
,
pRecv
->
connType
);
// check if it is already allocated
SRpcConn
**
ppConn
=
(
SRpcConn
**
)(
taosGetStrHashData
(
pRpc
->
hash
,
hashstr
));
...
...
@@ -567,6 +567,7 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
pConn
->
sid
=
sid
;
pConn
->
tranId
=
(
uint16_t
)(
rand
()
&
0xFFFF
);
pConn
->
ownId
=
htonl
(
pConn
->
sid
);
pConn
->
linkUid
=
pHead
->
linkUid
;
if
(
pRpc
->
afp
&&
(
*
pRpc
->
afp
)(
pConn
->
user
,
&
pConn
->
spi
,
&
pConn
->
encrypt
,
pConn
->
secret
,
pConn
->
ckey
)
<
0
)
{
tWarn
(
"%s %p, user not there"
,
pRpc
->
label
,
pConn
);
taosFreeId
(
pRpc
->
idPool
,
sid
);
// sid shall be released
...
...
@@ -601,8 +602,8 @@ static SRpcConn *rpcGetConnObj(SRpcInfo *pRpc, int sid, SRecvInfo *pRecv) {
}
if
(
pConn
)
{
if
(
memcmp
(
pConn
->
user
,
pHead
->
user
,
tListLen
(
pConn
->
user
))
!=
0
)
{
tTrace
(
"%s %p,
user:%s is not matched, received:%s"
,
pRpc
->
label
,
pConn
,
pConn
->
user
,
pHead
->
user
);
if
(
pConn
->
linkUid
!=
pHead
->
linkUid
)
{
tTrace
(
"%s %p,
linkUid:0x%x not matched, received:0x%x"
,
pRpc
->
label
,
pConn
,
pConn
->
linkUid
,
pHead
->
linkUid
);
terrno
=
TSDB_CODE_MISMATCHED_METER_ID
;
pConn
=
NULL
;
}
...
...
@@ -748,7 +749,6 @@ static SRpcConn *rpcProcessMsgHead(SRpcInfo *pRpc, SRecvInfo *pRecv) {
if
(
pRecv
->
port
)
pConn
->
peerPort
=
pRecv
->
port
;
if
(
pHead
->
port
)
pConn
->
peerPort
=
htons
(
pHead
->
port
);
if
(
pHead
->
uid
)
pConn
->
peerUid
=
pHead
->
uid
;
terrno
=
rpcCheckAuthentication
(
pConn
,
(
char
*
)
pHead
,
pRecv
->
msgLen
);
...
...
@@ -881,7 +881,7 @@ static void rpcSendQuickRsp(SRpcConn *pConn, int32_t code) {
pHead
->
tranId
=
pConn
->
inTranId
;
pHead
->
sourceId
=
pConn
->
ownId
;
pHead
->
destId
=
pConn
->
peerId
;
pHead
->
uid
=
0
;
pHead
->
linkUid
=
pConn
->
linkUid
;
memcpy
(
pHead
->
user
,
pConn
->
user
,
tListLen
(
pHead
->
user
));
pHead
->
code
=
htonl
(
code
);
...
...
@@ -905,7 +905,7 @@ static void rpcSendErrorMsgToPeer(SRecvInfo *pRecv, int32_t code) {
pReplyHead
->
tranId
=
pRecvHead
->
tranId
;
pReplyHead
->
sourceId
=
pRecvHead
->
destId
;
pReplyHead
->
destId
=
pRecvHead
->
sourceId
;
memcpy
(
pReplyHead
->
user
,
pRecvHead
->
user
,
tListLen
(
pReplyHead
->
user
))
;
pReplyHead
->
linkUid
=
pRecvHead
->
linkUid
;
pReplyHead
->
code
=
htonl
(
code
);
msgLen
=
sizeof
(
SRpcHead
);
...
...
@@ -951,8 +951,8 @@ static void rpcSendReqToServer(SRpcInfo *pRpc, SRpcReqContext *pContext) {
pHead
->
destId
=
pConn
->
peerId
;
pHead
->
destIp
=
pConn
->
destIp
;
pHead
->
port
=
0
;
pHead
->
uid
=
(
uint32_t
)((
int64_t
)
pConn
+
(
int64_t
)
getpid
())
;
memcpy
(
pHead
->
user
,
pConn
->
user
,
tListLen
(
pHead
->
user
));
pHead
->
linkUid
=
pConn
->
linkUid
;
if
(
!
pConn
->
secured
)
memcpy
(
pHead
->
user
,
pConn
->
user
,
tListLen
(
pHead
->
user
));
// set the connection parameters
pConn
->
outType
=
msgType
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录