Skip to content

Commit

Permalink
Adding Missing filters to CLIENT LIST and Dedup Parsing (#1401)
Browse files Browse the repository at this point in the history
Adds filter options to CLIENT LIST:

    * USER <username>
      Return clients authenticated by <username>.
    * ADDR <ip:port>
      Return clients connected from the specified address.
    * LADDR <ip:port>
      Return clients connected to the specified local address.
    * SKIPME (YES|NO)
      Exclude the current client from the list (default: no).
    * MAXAGE <maxage>
      Only list connections older than the specified age.

Modifies the ID filter to CLIENT KILL to allow multiple IDs

    * ID <client-id> [<client-id>...]
      Kill connections by client ids.


This makes CLIENT LIST and CLIENT KILL accept the same options.

For backward compatibility, the default value for SKIPME is NO for
CLIENT LIST and YES for CLIENT KILL.

The MAXAGE comes from CLIENT KILL, where it *keeps* clients with the
given max age and kills the older ones. This logic becomes weird for
CLIENT LIST, but is kept for similary with CLIENT KILL, for the use case
of first testing manually using CLIENT LIST, and then running CLIENT
KILL with the same filters.

The `ID client-id [client-id ...]` no longer needs to be the last
filter. The parsing logic determines if an argument is an ID or not
based on whether it can be parsed as an integer or not.

Partly addresses: #668

---------

Signed-off-by: Sarthak Aggarwal <[email protected]>
  • Loading branch information
sarthakaggarwal97 authored Jan 15, 2025
1 parent c5a1585 commit 6a8f068
Show file tree
Hide file tree
Showing 24 changed files with 867 additions and 535 deletions.
55 changes: 34 additions & 21 deletions src/commands.def

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/commands/client-caching.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "6.0.0",
"arity": 3,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientCachingCommand",
"command_flags": [
"NOSCRIPT",
"LOADING",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-capa.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "8.0.0",
"arity": -3,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientCapaCommand",
"command_flags": [
"NOSCRIPT",
"LOADING",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-getname.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "2.6.9",
"arity": 2,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientGetNameCommand",
"command_flags": [
"NOSCRIPT",
"LOADING",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-getredir.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "6.0.0",
"arity": 2,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientGetredirCommand",
"command_flags": [
"NOSCRIPT",
"LOADING",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-help.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "5.0.0",
"arity": 2,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientHelpCommand",
"command_flags": [
"LOADING",
"STALE",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-id.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "5.0.0",
"arity": 2,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientIDCommand",
"command_flags": [
"NOSCRIPT",
"LOADING",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-import-source.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "8.1.0",
"arity": 3,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientImportSourceCommand",
"command_flags": [
"NOSCRIPT",
"LOADING",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "6.2.0",
"arity": 2,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientInfoCommand",
"command_flags": [
"NOSCRIPT",
"LOADING",
Expand Down
7 changes: 6 additions & 1 deletion src/commands/client-kill.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "2.4.0",
"arity": -3,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientKillCommand",
"history": [
[
"2.8.12",
Expand Down Expand Up @@ -35,6 +35,10 @@
[
"8.0.0",
"Replaced `master` `TYPE` with `primary`. `master` still supported for backward compatibility."
],
[
"8.1.0",
"`ID` option accepts multiple IDs."
]
],
"command_flags": [
Expand Down Expand Up @@ -68,6 +72,7 @@
"name": "client-id",
"type": "integer",
"optional": true,
"multiple": true,
"since": "2.8.12"
},
{
Expand Down
55 changes: 54 additions & 1 deletion src/commands/client-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "2.4.0",
"arity": -2,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientListCommand",
"history": [
[
"2.8.12",
Expand Down Expand Up @@ -35,6 +35,10 @@
[
"8.0.0",
"Replaced `master` `TYPE` with `primary`. `master` still supported for backward compatibility."
],
[
"8.1.0",
"Added filters USER, ADDR, LADDR, SKIPME, and MAXAGE"
]
],
"command_flags": [
Expand Down Expand Up @@ -91,6 +95,55 @@
"optional": true,
"multiple": true,
"since": "6.2.0"
},
{
"token": "USER",
"name": "username",
"type": "string",
"optional": true,
"since": "8.1.0"
},
{
"token": "ADDR",
"name": "addr",
"display": "ip:port",
"type": "string",
"optional": true,
"since": "8.1.0"
},
{
"token": "LADDR",
"name": "laddr",
"display": "ip:port",
"type": "string",
"optional": true,
"since": "8.1.0"
},
{
"token": "SKIPME",
"name": "skipme",
"type": "oneof",
"optional": true,
"since": "8.1.0",
"arguments": [
{
"name": "yes",
"type": "pure-token",
"token": "YES"
},
{
"name": "no",
"type": "pure-token",
"token": "NO"
}
]
},
{
"token": "MAXAGE",
"name": "maxage",
"type": "integer",
"optional": true,
"since": "8.1.0"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-no-evict.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "7.0.0",
"arity": 3,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientNoEvictCommand",
"command_flags": [
"ADMIN",
"NOSCRIPT",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-no-touch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "7.2.0",
"arity": 3,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientNoTouchCommand",
"command_flags": [
"NOSCRIPT",
"LOADING",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-pause.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "3.0.0",
"arity": -3,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientPauseCommand",
"history": [
[
"6.2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-reply.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "3.2.0",
"arity": 3,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientReplyCommand",
"command_flags": [
"NOSCRIPT",
"LOADING",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-setname.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "2.6.9",
"arity": 3,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientSetNameCommand",
"command_flags": [
"NOSCRIPT",
"LOADING",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-tracking.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "6.0.0",
"arity": -3,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientTrackingCommand",
"command_flags": [
"NOSCRIPT",
"LOADING",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-trackinginfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "6.2.0",
"arity": 2,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientTrackingInfoCommand",
"command_flags": [
"NOSCRIPT",
"LOADING",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-unblock.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "5.0.0",
"arity": -3,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientUnblockCommand",
"command_flags": [
"ADMIN",
"NOSCRIPT",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/client-unpause.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"since": "6.2.0",
"arity": 2,
"container": "CLIENT",
"function": "clientCommand",
"function": "clientUnpauseCommand",
"command_flags": [
"ADMIN",
"NOSCRIPT",
Expand Down
1 change: 1 addition & 0 deletions src/commands/client.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"complexity": "Depends on subcommand.",
"group": "connection",
"since": "2.4.0",
"function": "clientCommand",
"arity": -2,
"command_flags": [
"SENTINEL"
Expand Down
Loading

0 comments on commit 6a8f068

Please sign in to comment.