Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
288799e0
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
288799e0
编写于
3月 18, 2010
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed redis-cli auth code
上级
2a1198b4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
30 deletion
+12
-30
redis-cli.c
redis-cli.c
+11
-30
test-redis.tcl
test-redis.tcl
+1
-0
未找到文件。
redis-cli.c
浏览文件 @
288799e0
...
@@ -52,7 +52,7 @@ static struct config {
...
@@ -52,7 +52,7 @@ static struct config {
long
repeat
;
long
repeat
;
int
dbnum
;
int
dbnum
;
int
interactive
;
int
interactive
;
char
*
auth
pw
;
char
*
auth
;
}
config
;
}
config
;
struct
redisCommand
{
struct
redisCommand
{
...
@@ -307,27 +307,6 @@ static int selectDb(int fd) {
...
@@ -307,27 +307,6 @@ static int selectDb(int fd) {
return
0
;
return
0
;
}
}
static
int
cliLogin
(
int
fd
)
{
int
retval
=
1
;
sds
cmd
;
char
type
;
if
(
config
.
authpw
[
0
]
!=
'\0'
)
{
cmd
=
sdsempty
();
cmd
=
sdscatprintf
(
cmd
,
"AUTH %s
\r\n
"
,
config
.
authpw
);
anetWrite
(
fd
,
cmd
,
sdslen
(
cmd
));
anetRead
(
fd
,
&
type
,
1
);
if
(
type
==
'+'
)
retval
=
0
;
int
ret2
=
cliReadSingleLineReply
(
fd
,
1
);
if
(
ret2
)
close
(
fd
);
}
else
{
retval
=
0
;
}
return
retval
;
}
static
int
cliSendCommand
(
int
argc
,
char
**
argv
)
{
static
int
cliSendCommand
(
int
argc
,
char
**
argv
)
{
struct
redisCommand
*
rc
=
lookupCommand
(
argv
[
0
]);
struct
redisCommand
*
rc
=
lookupCommand
(
argv
[
0
]);
int
fd
,
j
,
retval
=
0
;
int
fd
,
j
,
retval
=
0
;
...
@@ -354,13 +333,6 @@ static int cliSendCommand(int argc, char **argv) {
...
@@ -354,13 +333,6 @@ static int cliSendCommand(int argc, char **argv) {
return
1
;
return
1
;
}
}
/* Login if necessary */
retval
=
cliLogin
(
fd
);
if
(
retval
)
{
fprintf
(
stderr
,
"Authentication failed
\n
"
);
return
1
;
}
while
(
config
.
repeat
--
)
{
while
(
config
.
repeat
--
)
{
/* Build the command to send */
/* Build the command to send */
cmd
=
sdsempty
();
cmd
=
sdsempty
();
...
@@ -429,7 +401,7 @@ static int parseOptions(int argc, char **argv) {
...
@@ -429,7 +401,7 @@ static int parseOptions(int argc, char **argv) {
config
.
dbnum
=
atoi
(
argv
[
i
+
1
]);
config
.
dbnum
=
atoi
(
argv
[
i
+
1
]);
i
++
;
i
++
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"-a"
)
&&
!
lastarg
)
{
}
else
if
(
!
strcmp
(
argv
[
i
],
"-a"
)
&&
!
lastarg
)
{
config
.
auth
pw
=
argv
[
i
+
1
];
config
.
auth
=
argv
[
i
+
1
];
i
++
;
i
++
;
}
else
if
(
!
strcmp
(
argv
[
i
],
"-i"
))
{
}
else
if
(
!
strcmp
(
argv
[
i
],
"-i"
))
{
config
.
interactive
=
1
;
config
.
interactive
=
1
;
...
@@ -497,6 +469,14 @@ static void repl() {
...
@@ -497,6 +469,14 @@ static void repl() {
char
*
line
=
buffer
;
char
*
line
=
buffer
;
char
**
ap
,
*
args
[
max
];
char
**
ap
,
*
args
[
max
];
if
(
config
.
auth
!=
NULL
)
{
char
*
authargv
[
2
];
authargv
[
0
]
=
"AUTH"
;
authargv
[
1
]
=
config
.
auth
;
cliSendCommand
(
2
,
convertToSds
(
2
,
authargv
));
}
while
(
prompt
(
line
,
size
))
{
while
(
prompt
(
line
,
size
))
{
argc
=
0
;
argc
=
0
;
...
@@ -528,6 +508,7 @@ int main(int argc, char **argv) {
...
@@ -528,6 +508,7 @@ int main(int argc, char **argv) {
config
.
repeat
=
1
;
config
.
repeat
=
1
;
config
.
dbnum
=
0
;
config
.
dbnum
=
0
;
config
.
interactive
=
0
;
config
.
interactive
=
0
;
config
.
auth
=
NULL
;
firstarg
=
parseOptions
(
argc
,
argv
);
firstarg
=
parseOptions
(
argc
,
argv
);
argc
-=
firstarg
;
argc
-=
firstarg
;
...
...
test-redis.tcl
浏览文件 @
288799e0
...
@@ -1763,6 +1763,7 @@ proc main {server port} {
...
@@ -1763,6 +1763,7 @@ proc main {server port} {
set rank
[
$r
zrank myzset $ele
]
set rank
[
$r
zrank myzset $ele
]
if
{
$rank
!= $index
}
{
if
{
$rank
!= $index
}
{
set err
"
$ele
RANK is wrong! (
$rank
!=
$index
)"
set err
"
$ele
RANK is wrong! (
$rank
!=
$index
)"
exit
break
break
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录