Klemens Nanni <[email protected]> writes:

> On Sun, Feb 05, 2017 at 12:27:19AM +0100, Jeremie Courreges-Anglas wrote:
>>The colons used in IPv6 addresses conflicts with the proxy port
>>specification.  Do the right thing for -x ::1:8080, [::1] and
>>[::1]:8080.
> With this patch '-x ::1' is still broken. I think we should either
> require/enforce square brackets for IPv6 addresses or allow all possible
> notations. Otherwise having '-x 127.0.0.1' working but not '-x ::1'
> seems both confusing and broken to me.

-x ::1 is ambiguous, -x 127.0.0.1 isn't.  It's just a fact.  The
implementation in nc(1) was based on what ftp(1) accepts.  I don't
really see the point in writing code to make ftp(1) and nc(1) behave
differently, nor to prevent people from using stuff that works now in
ftp(1).

This being said, the error message from remote_connect isn't very
useful, especially in that case.  And the manpage could document square
brackets.

Comments / ok?


Index: nc.1
===================================================================
RCS file: /cvs/src/usr.bin/nc/nc.1,v
retrieving revision 1.81
diff -u -p -r1.81 nc.1
--- nc.1        26 Jan 2017 22:59:55 -0000      1.81
+++ nc.1        5 Feb 2017 03:50:47 -0000
@@ -327,6 +327,9 @@ If
 .Ar port
 is not specified, the well-known port for the proxy protocol is used (1080
 for SOCKS, 3128 for HTTPS).
+An IPv6 address can be specified unambiguously by enclosing
+.Ar proxy_address
+in square brackets.
 .It Fl z
 Specifies that
 .Nm
Index: netcat.c
===================================================================
RCS file: /cvs/src/usr.bin/nc/netcat.c,v
retrieving revision 1.172
diff -u -p -r1.172 netcat.c
--- netcat.c    5 Feb 2017 01:39:14 -0000       1.172
+++ netcat.c    5 Feb 2017 03:50:48 -0000
@@ -856,7 +856,8 @@ remote_connect(const char *host, const c
        int s = -1, error, on = 1, save_errno;
 
        if ((error = getaddrinfo(host, port, &hints, &res0)))
-               errx(1, "getaddrinfo: %s", gai_strerror(error));
+               errx(1, "getaddrinfo for host \"%s\" port %s: %s", host,
+                   port ? port : "any", gai_strerror(error));
 
        for (res = res0; res; res = res->ai_next) {
                if ((s = socket(res->ai_family, res->ai_socktype |

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to