Skip to content

Commit

Permalink
support IPv6 redirection message.
Browse files Browse the repository at this point in the history
  • Loading branch information
sewenew committed Oct 8, 2024
1 parent 703d57e commit 89c6e10
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/sw/redis++/shards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ RedirectionError::RedirectionError(const std::string &msg): ReplyError(msg) {
std::pair<Slot, Node> RedirectionError::_parse_error(const std::string &msg) const {
// "slot ip:port"
auto space_pos = msg.find(" ");
auto colon_pos = msg.find(":");
// There're colons in IPv6 address, so we need to find the last colon.
auto colon_pos = msg.rfind(":");
if (space_pos == std::string::npos
|| colon_pos == std::string::npos
|| colon_pos < space_pos) {
throw ProtoError("Invalid ASK error message: " + msg);
throw ProtoError("invalid redirection error message: " + msg);
}

try {
Expand All @@ -43,7 +44,7 @@ std::pair<Slot, Node> RedirectionError::_parse_error(const std::string &msg) con

return {slot, {host, port}};
} catch (const std::exception &) {
throw ProtoError("Invalid ASK error message: " + msg);
throw ProtoError("invalid redirection error message: " + msg);
}
}

Expand Down

0 comments on commit 89c6e10

Please sign in to comment.