mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 08:08:53 -05:00
redis-cli: Support URIs with IPv6 (#11834)
Co-authored-by: hrliu <hrliu@alauda.io>
This commit is contained in:
parent
07ed0eafa9
commit
6bf9b144ef
@ -352,10 +352,20 @@ void parseRedisUri(const char *uri, const char* tool_name, cliConnInfo *connInfo
|
||||
path = strchr(curr, '/');
|
||||
if (*curr != '/') {
|
||||
host = path ? path - 1 : end;
|
||||
if (*curr == '[') {
|
||||
curr += 1;
|
||||
if ((port = strchr(curr, ']'))) {
|
||||
if (*(port+1) == ':') {
|
||||
connInfo->hostport = atoi(port + 2);
|
||||
}
|
||||
host = port - 1;
|
||||
}
|
||||
} else {
|
||||
if ((port = strchr(curr, ':'))) {
|
||||
connInfo->hostport = atoi(port + 1);
|
||||
host = port - 1;
|
||||
}
|
||||
}
|
||||
sdsfree(connInfo->hostip);
|
||||
connInfo->hostip = sdsnewlen(curr, host - curr + 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user