[PATCH] IPv6 bracket notation for listen addresses in -p
Matt Johnston
matt at ucc.asn.au
Fri Dec 14 22:30:03 WST 2012
Hi,
Thanks for that, I'll make sure it makes the next release.
Cheers,
Matt
On Tue, Dec 11, 2012 at 12:11:45AM -0500, Ben Jencks wrote:
> Updates parsing of the -p option to handle [2001:dba::]:22 style IPv6
> addresses. This allows binding to specific IPv6 addresses, rather than
> having to bind to all addresses in order to get any IPv6 support. For
> example, you can now listen on IPv6 only with -p [::]:22.
>
> This has been done before at [1], but I thought that patch
> was kind of ugly so I wrote my own.
>
> Please CC me on responses as I'm not subscribed to the list.
>
> [1]
> https://lists.openwrt.org/pipermail/openwrt-devel/2009-May/004299.html
>
> diff -ur dropbear-2012.55.orig/svr-runopts.c dropbear-2012.55/svr-runopts.c
> --- dropbear-2012.55.orig/svr-runopts.c 2012-02-23 08:47:06.000000000 -0500
> +++ dropbear-2012.55/svr-runopts.c 2012-12-10 23:17:28.496729985 -0500
> @@ -324,8 +324,23 @@
> /* We don't free it, it becomes part of the runopt state */
> myspec = m_strdup(spec);
>
> - /* search for ':', that separates address and port */
> - svr_opts.ports[svr_opts.portcount] = strchr(myspec, ':');
> + if (myspec[0] == '[') {
> + myspec++;
> + svr_opts.ports[svr_opts.portcount] = strchr(myspec, ']');
> + if (svr_opts.ports[svr_opts.portcount] == NULL) {
> + /* Unmatched [ -> exit */
> + dropbear_exit("Bad listen address");
> + }
> + svr_opts.ports[svr_opts.portcount][0] = '\0';
> + svr_opts.ports[svr_opts.portcount]++;
> + if (svr_opts.ports[svr_opts.portcount][0] != ':') {
> + /* Missing port -> exit */
> + dropbear_exit("Missing port");
> + }
> + } else {
> + /* search for ':', that separates address and port */
> + svr_opts.ports[svr_opts.portcount] = strchr(myspec, ':');
> + }
>
> if (svr_opts.ports[svr_opts.portcount] == NULL) {
> /* no ':' -> the whole string specifies just a port */
More information about the Dropbear
mailing list