From 0b088d8d81a09e5f66f227eba41aa526c81f0887 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 18 Nov 2012 18:08:14 +1100 Subject: [PATCH] Provide rudimentary support for literal ipv6 addresses when parsing stratum URLs. --- util.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/util.c b/util.c index d9d1d48f..3b07df4d 100644 --- a/util.c +++ b/util.c @@ -833,7 +833,7 @@ double tdiff(struct timeval *end, struct timeval *start) bool extract_sockaddr(struct pool *pool, char *url) { - char *url_begin, *url_end, *port_start = NULL; + char *url_begin, *url_end, *ipv6_begin, *ipv6_end, *port_start = NULL; char url_address[256], port[6]; int url_len, port_len = 0; @@ -843,7 +843,14 @@ bool extract_sockaddr(struct pool *pool, char *url) url_begin = url; else url_begin += 2; - url_end = strstr(url_begin, ":"); + + /* Look for numeric ipv6 entries */ + ipv6_begin = strstr(url_begin, "["); + ipv6_end = strstr(url_begin, "]"); + if (ipv6_begin && ipv6_end && ipv6_end > ipv6_begin) + url_end = strstr(ipv6_end, ":"); + else + url_end = strstr(url_begin, ":"); if (url_end) { url_len = url_end - url_begin; port_len = strlen(url_begin) - url_len - 1;