[PATCH android] config: fix wrong Peer endpoint string format
Jason A. Donenfeld
Jason at zx2c4.com
Thu Aug 16 21:09:07 CEST 2018
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 at 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
More information about the WireGuard
mailing list