Skip to content

Commit 6ee1a59

Browse files
committed
add password check
1 parent c9c484e commit 6ee1a59

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

examples/source/app.d

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ void main()
55
{
66
writeln("Edit source/app.d to start your project.");
77

8-
auto redis = new Redis("redis.host = r-uf6da5702d0bbeb4.redis.rds.aliyuncs.com",6379,"Putao123");
8+
auto redis = new Redis("10.1.11.168",6379,"123456");
99

1010
redis.set("redie_User_31","password");
11-
int i = 10;
12-
while(i>0){
13-
assert(cast(ubyte[])redis.get("redie_User_31") == [7, 118, 0, 2, 31, 0, 0, 0, 4, 11, 0, 49, 51, 51, 51, 51, 51, 51, 51, 51, 48, 53, 4, 2, 0, 48, 53, 4, 12, 0, 72, 113, 108, 106, 53, 76, 121, 72, 55, 121, 107, 108, 4, 40, 0, 53, 67, 56, 56, 53, 68, 57, 49, 67, 50, 49, 57, 52, 69, 50, 69, 50, 52, 69, 50, 70, 65, 50, 69, 52, 65, 48, 55, 70, 54, 67, 67, 51, 56, 48, 50, 67, 53, 67, 54, 4, 0, 0, 4, 2, 0, 56, 54, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 57, 69, -61, 89, 0, 0, 0, 0, 3, 30, 45, -58, 89, 0, 0, 0, 0]);
14-
i--;
15-
}
11+
writeln(redis.get("redie_User_31"));
1612
}

source/redis/redis.d

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ public class Redis
3737
auto conn = new TcpSocket(new InternetAddress(host, port));
3838
addr = host~":"~to!string(port);
3939
conns[addr] = conn;
40+
writeln(password);
41+
writeln("AUTH "~password);
4042
if(password.length > 0)
41-
conn.send("AUTH "~password);
43+
conn.send(toMultiBulk("AUTH", password));
4244
}
4345

4446
override string toString()

0 commit comments

Comments
 (0)