From 887fc2b37bcdc03f1980225a8876272e3f41f967 Mon Sep 17 00:00:00 2001 From: guozhihao3 Date: Fri, 1 Aug 2025 17:11:51 +0800 Subject: [PATCH] feat: support client info command --- src/server/server_family.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/server/server_family.cc b/src/server/server_family.cc index f488d13e7936..e2bd0394978a 100644 --- a/src/server/server_family.cc +++ b/src/server/server_family.cc @@ -384,6 +384,16 @@ void ClientGetName(CmdArgList args, SinkReplyBuilder* builder, ConnectionContext } } +void ClientInfo(CmdArgList args, SinkReplyBuilder* builder, ConnectionContext* cntx) { + if (!args.empty()) { + return builder->SendError(facade::kSyntaxErr); + } + auto* conn = cntx->conn(); + string info = conn->GetClientInfo(); + auto* rb = static_cast(builder); + return rb->SendVerbatimString(info); +} + void ClientList(CmdArgList args, absl::Span listeners, SinkReplyBuilder* builder, ConnectionContext* cntx) { if (!args.empty()) { @@ -2272,6 +2282,8 @@ void ClientHelp(SinkReplyBuilder* builder) { " Kill connections made to specified local address", " * ID ", " Kill connections by client id.", + "INFO", + " Return information about the current client connection.", "LIST", " Return information about client connections.", "UNPAUSE", @@ -2304,6 +2316,8 @@ void ServerFamily::Client(CmdArgList args, const CommandContext& cmd_cntx) { return ClientSetName(sub_args, builder, cntx); } else if (sub_cmd == "GETNAME") { return ClientGetName(sub_args, builder, cntx); + } else if (sub_cmd == "INFO") { + return ClientInfo(sub_args, builder, cntx); } else if (sub_cmd == "LIST") { return ClientList(sub_args, absl::MakeSpan(listeners_), builder, cntx); } else if (sub_cmd == "PAUSE") {