port forwarding trouble

Sergio Gelato Sergio.Gelato at astro.su.se
Thu Aug 11 01:53:36 EST 2005


* Darren Tucker [2005-08-11 00:35:10 +1000]:
> It occurrs to me that since it doesn't actually need *parse* the
> host:port identifiers then factoring out that code is a waste of time,
> so this diff is much simpler :-)

Remind me: why do you need to check for the second ':' before deciding to
use square brackets? As far as avoiding ambiguity is concerned, I would 
argue that even a single ':' in the host string is enough to warrant 
bracketing.

It is true that an IPv6 address cannot be written with less than two ':'.
What I don't see right now is under what other circumstances host could
contain a single ':'. If, as I believe, it cannot, then you might as
well drop the second strchr() call. And even if it can, bracketing may
still be appropriate.

Isn't the reason for your two-':' heuristic that ListenAddress lines can
already be in host:port form? I don't think that's an issue here.

> +	if ((p = strchr(host, ':')) != NULL && strchr(p+1, ':') != NULL)
> +		ret = asprintf(&p, "[%s]:%hd", host, port); /* IPv6 */
> +	else
> +		ret = asprintf(&p, "%s:%hd", host, port);




More information about the openssh-unix-dev mailing list