Development discussion of WireGuard
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: gang.zhao.42@gmail.com
Cc: WireGuard mailing list <wireguard@lists.zx2c4.com>
Subject: Re: [PATCH android] config: fix wrong Peer endpoint string format
Date: Thu, 16 Aug 2018 12:09:07 -0700	[thread overview]
Message-ID: <CAHmME9oUA0JgspMdYNy96YyjeFQYA_cb59=4vd2t4C-eUrKOpQ@mail.gmail.com> (raw)
In-Reply-To: <1ddd5012b4e54c6381079ceab335576fcc530c60.1534172353.git.gang.zhao.42@gmail.com>

Hi Gang,

Thanks for the patch, I'll merge the first hunk of this but not the
second, because:

On Thu, Aug 16, 2018 at 11:58 AM Zhao Gang <gang.zhao.42@gmail.com> wrote:
> -        return String.format("%s:%d", endpoint.getHostString(), endpoint.getPort());
> +
> +        if (endpoint.getHostString().contains(":") && !endpoint.getHostString().contains("["))
> +            return String.format("[%s]:%d", endpoint.getHostString(), endpoint.getPort());
> +        else
> +            return String.format("%s:%d", endpoint.getHostString(), endpoint.getPort());

This seems like a fix for the bug. But:

> -        if (endpoint.getAddress() instanceof Inet6Address)
> -            return String.format("[%s]:%d",
> -                    endpoint.getAddress().getHostAddress(),
> -                    endpoint.getPort());
> -        return String.format("%s:%d",
> -                endpoint.getAddress().getHostAddress(),
> -                endpoint.getPort());

The purpose of the code here is to resolve the hostname to an IP
address, and then return ip+port, with no hostnames in it. Replacing
it with a call to the prior fixed function isn't the intended
behavior.

I've committed your fix here as:
https://git.zx2c4.com/wireguard-android/commit/?id=ace2a77bc9019d050112bed5a5d1eb2a3363d971

Thanks again,
Jason

  reply	other threads:[~2018-08-16 18:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-06 15:38 android: handling ipv6 literals Peter Gervai
2018-08-13 15:12 ` [PATCH android] config: fix wrong Peer endpoint string format Zhao Gang
2018-08-16 19:09   ` Jason A. Donenfeld [this message]
2018-08-16  9:04 ` [PATCH android v2] " Zhao Gang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHmME9oUA0JgspMdYNy96YyjeFQYA_cb59=4vd2t4C-eUrKOpQ@mail.gmail.com' \
    --to=jason@zx2c4.com \
    --cc=gang.zhao.42@gmail.com \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).