Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
cec388f2
Commit
cec388f2
authored
Apr 30, 2020
by
antirez
Browse files
CLIENT KILL USER <username>.
parent
fd8f39a2
Changes
1
Show whitespace changes
Inline
Side-by-side
src/networking.c
View file @
cec388f2
...
@@ -2101,6 +2101,7 @@ void clientCommand(client *c) {
...
@@ -2101,6 +2101,7 @@ void clientCommand(client *c) {
"KILL <option> <value> [option value ...] -- Kill connections. Options are:",
"KILL <option> <value> [option value ...] -- Kill connections. Options are:",
" ADDR <ip:port> -- Kill connection made from <ip:port>",
" ADDR <ip:port> -- Kill connection made from <ip:port>",
" TYPE (normal|master|replica|pubsub) -- Kill connections by type.",
" TYPE (normal|master|replica|pubsub) -- Kill connections by type.",
" USER <username> -- Kill connections authenticated with such user.",
" SKIPME (yes|no) -- Skip killing current connection (default: yes).",
" SKIPME (yes|no) -- Skip killing current connection (default: yes).",
"LIST [options ...] -- Return information about client connections. Options:",
"LIST [options ...] -- Return information about client connections. Options:",
" TYPE (normal|master|replica|pubsub) -- Return clients of specified type.",
" TYPE (normal|master|replica|pubsub) -- Return clients of specified type.",
...
@@ -2151,6 +2152,7 @@ NULL
...
@@ -2151,6 +2152,7 @@ NULL
/* CLIENT KILL <ip:port>
/* CLIENT KILL <ip:port>
* CLIENT KILL <option> [value] ... <option> [value] */
* CLIENT KILL <option> [value] ... <option> [value] */
char *addr = NULL;
char *addr = NULL;
user *user = NULL;
int type = -1;
int type = -1;
uint64_t id = 0;
uint64_t id = 0;
int skipme = 1;
int skipme = 1;
...
@@ -2182,6 +2184,14 @@ NULL
...
@@ -2182,6 +2184,14 @@ NULL
}
}
} else if (!strcasecmp(c->argv[i]->ptr,"addr") && moreargs) {
} else if (!strcasecmp(c->argv[i]->ptr,"addr") && moreargs) {
addr = c->argv[i+1]->ptr;
addr = c->argv[i+1]->ptr;
} else if (!strcasecmp(c->argv[i]->ptr,"user") && moreargs) {
user = ACLGetUserByName(c->argv[i+1]->ptr,
sdslen(c->argv[i+1]->ptr));
if (user == NULL) {
addReplyErrorFormat(c,"No such user '%s'",
(char*) c->argv[i+1]->ptr);
return;
}
} else if (!strcasecmp(c->argv[i]->ptr,"skipme") && moreargs) {
} else if (!strcasecmp(c->argv[i]->ptr,"skipme") && moreargs) {
if (!strcasecmp(c->argv[i+1]->ptr,"yes")) {
if (!strcasecmp(c->argv[i+1]->ptr,"yes")) {
skipme = 1;
skipme = 1;
...
@@ -2209,6 +2219,7 @@ NULL
...
@@ -2209,6 +2219,7 @@ NULL
if (addr && strcmp(getClientPeerId(client),addr) != 0) continue;
if (addr && strcmp(getClientPeerId(client),addr) != 0) continue;
if (type != -1 && getClientType(client) != type) continue;
if (type != -1 && getClientType(client) != type) continue;
if (id != 0 && client->id != id) continue;
if (id != 0 && client->id != id) continue;
if (user && client->user != user) continue;
if (c == client && skipme) continue;
if (c == client && skipme) continue;
/* Kill it. */
/* Kill it. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment