Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DR-2672 - Dummy stub for client setinfo and ignoring private client auth message in pubsub response #39

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ struct SupportedCommands {
CONSTRUCT_ON_FIRST_USE(absl::flat_hash_set<std::string>, "subscribe", "psubscribe", "unsubscribe", "punsubscribe","quit", "ping");
}

static const absl::flat_hash_set<std::string>& subcrStateNoArgallowedCommands() {
CONSTRUCT_ON_FIRST_USE(absl::flat_hash_set<std::string>, "unsubscribe", "punsubscribe","quit", "ping");
}

/**
* @return commands that make a client to enter subscribed state.
*/
Expand Down Expand Up @@ -113,7 +117,7 @@ struct SupportedCommands {
* @return client sub commands thats supported
*/
static const absl::flat_hash_set<std::string>& clientSubCommands() {
CONSTRUCT_ON_FIRST_USE(absl::flat_hash_set<std::string>, "getname","setname");
CONSTRUCT_ON_FIRST_USE(absl::flat_hash_set<std::string>, "getname","setname", "setinfo");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -936,9 +936,13 @@ SplitRequestPtr PubSubRequest::create(Router& router, Common::Redis::RespValuePt
int32_t redisShardsCount=0;

if (Common::Redis::SupportedCommands::subscriptionCommands().contains(command_name) && incoming_request->asArray().size() < 2) {
ENVOY_LOG(debug, "Invalid request: '{}'", incoming_request->toString());
callbacks.onResponse(Common::Redis::Utility::makeError(Response::get().InvalidRequest));
return nullptr;
if (!Common::Redis::SupportedCommands::subcrStateNoArgallowedCommands().contains(command_name)) {
ENVOY_LOG(debug, "Invalid request: '{}'", incoming_request->toString());
callbacks.onResponse(Common::Redis::Utility::makeError(Response::get().InvalidRequest));
return nullptr;
} else {
ENVOY_LOG(debug, "No arguments acceptable for command: '{}'", command_name);
}
}


Expand Down Expand Up @@ -1118,9 +1122,14 @@ void PubSubMessageHandler::handleChannelMessageCustom(Common::Redis::RespValuePt
ENVOY_LOG(debug, "message received on channel '{}' on shardIndex : '{}'", value->toString(),shardIndex);

if (value->type() != Common::Redis::RespType::Array ||
value->asArray()[0].type() != Common::Redis::RespType::BulkString) {
ENVOY_LOG(error, "unexpected message format: '{}'", value->toString());
return;
value->asArray()[0].type() != Common::Redis::RespType::BulkString) {
Sasidharan-Gopal marked this conversation as resolved.
Show resolved Hide resolved
if (value->type() == Common::Redis::RespType::SimpleString && value->asString() == "OK") {
ENVOY_LOG(debug, "This is a private client creation auth command response - '{}'", value->toString());
return;
} else {
ENVOY_LOG(error, "unexpected message format: '{}'", value->toString());
return;
}
}

std::string message_type = value->asArray()[0].asString();
Expand Down Expand Up @@ -2007,6 +2016,9 @@ SplitRequestPtr InstanceImpl::makeRequest(Common::Redis::RespValuePtr&& request,
ClientResp->type(Common::Redis::RespType::BulkString);
ClientResp->asString() = callbacks.getClientname();
}
} else if (sub_command == "setinfo") {
ClientResp->type(Common::Redis::RespType::SimpleString);
ClientResp->asString() = "OK";
}
callbacks.onResponse(std::move(ClientResp));
return nullptr;
Expand Down