Skip to content

Commit 3257aa8

Browse files
committed
support IPv6 redirection message.
1 parent 9f458f1 commit 3257aa8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/sw/redis++/shards.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ RedirectionError::RedirectionError(const std::string &msg): ReplyError(msg) {
2727
std::pair<Slot, Node> RedirectionError::_parse_error(const std::string &msg) const {
2828
// "slot ip:port"
2929
auto space_pos = msg.find(" ");
30-
auto colon_pos = msg.find(":");
30+
// There're colons in IPv6 address, so we need to find the last colon.
31+
auto colon_pos = msg.rfind(":");
3132
if (space_pos == std::string::npos
3233
|| colon_pos == std::string::npos
3334
|| colon_pos < space_pos) {
34-
throw ProtoError("Invalid ASK error message: " + msg);
35+
throw ProtoError("invalid redirection error message: " + msg);
3536
}
3637

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

4445
return {slot, {host, port}};
4546
} catch (const std::exception &) {
46-
throw ProtoError("Invalid ASK error message: " + msg);
47+
throw ProtoError("invalid redirection error message: " + msg);
4748
}
4849
}
4950

0 commit comments

Comments
 (0)