From: Remi Collet Date: Tue, 26 Jan 2021 13:34:18 +0000 (+0100) Subject: accept [IPv6] on memcached_servers_parse X-Git-Tag: 1.1.0-beta3~9 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=4966c12cc51f6ab1658e705bded146f8fd872b27;p=awesomized%2Flibmemcached accept [IPv6] on memcached_servers_parse --- diff --git a/src/libmemcached/parse.cc b/src/libmemcached/parse.cc index 12431222..5bf6fac2 100644 --- a/src/libmemcached/parse.cc +++ b/src/libmemcached/parse.cc @@ -44,8 +44,17 @@ memcached_server_list_st memcached_servers_parse(const char *server_strings) { begin_ptr = end_ptr; } - ptr = strchr(buffer, ':'); - + ptr = strchr(buffer, '['); + if (ptr) { + ptr2 = strchr(ptr+1, ']'); + } + if (ptr && ptr2) { + // [IPv6]:port + ptr = strchr(ptr2+1, ':'); + } else { + // IPv4:port or name:port + ptr = strchr(buffer, ':'); + } in_port_t port = 0; if (ptr) { ptr[0] = 0;