aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gg.11
-rw-r--r--gg.c23
2 files changed, 15 insertions, 9 deletions
diff --git a/gg.1 b/gg.1
index 0483a06..19eaa18 100644
--- a/gg.1
+++ b/gg.1
@@ -82,6 +82,7 @@ and
to do the request instead of the ones extracted by the IRI.
.Ar port
is by default 1965.
+IPv6 addresses have to be wrapped in braces, for e.g. [::1].
.It Fl q
Don't print server error messages to standard error.
.It Fl T Ar seconds
diff --git a/gg.c b/gg.c
index 5ca3fc7..5b14e9f 100644
--- a/gg.c
+++ b/gg.c
@@ -362,22 +362,27 @@ parse_debug(const char *arg)
}
static void
-parse_proxy(const char *arg)
+parse_proxy(char *arg)
{
char *at;
- if ((proxy_host = strdup(arg)) == NULL)
- err(1, "strdup");
-
+ proxy_host = arg;
proxy_port = "1965";
- if ((at = strchr(proxy_host, ':')) == NULL)
+ if (*proxy_host == '[') {
+ if ((at = strchr(proxy_host, ']')) == NULL)
+ errx(1, "invalid host: %s", proxy_host);
+ proxy_host++;
+ *at++ = '\0';
+ if (*at == '\0')
+ return;
+ if (*at != ':')
+ errx(1, "invalid port specification: %s", at);
+ } else if ((at = strchr(proxy_host, ':')) == NULL)
return;
- *at = '\0';
- proxy_port = ++at;
- if (strchr(proxy_port, ':') != NULL)
- errx(1, "invalid port %s", proxy_port);
+ *at++ = '\0';
+ proxy_port = at;
}
int