From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Jason@zx2c4.com Received: from krantz.zx2c4.com (localhost [127.0.0.1]) by krantz.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 5f8e5df5 for ; Thu, 16 Aug 2018 18:57:09 +0000 (UTC) Received: from frisell.zx2c4.com (frisell.zx2c4.com [192.95.5.64]) by krantz.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 31af4789 for ; Thu, 16 Aug 2018 18:57:09 +0000 (UTC) Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id bc2612fe for ; Thu, 16 Aug 2018 18:55:55 +0000 (UTC) Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 4e257a28 (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128:NO) for ; Thu, 16 Aug 2018 18:55:55 +0000 (UTC) Received: by mail-oi0-f46.google.com with SMTP id q11-v6so9935806oic.12 for ; Thu, 16 Aug 2018 12:09:19 -0700 (PDT) MIME-Version: 1.0 References: <1ddd5012b4e54c6381079ceab335576fcc530c60.1534172353.git.gang.zhao.42@gmail.com> In-Reply-To: <1ddd5012b4e54c6381079ceab335576fcc530c60.1534172353.git.gang.zhao.42@gmail.com> From: "Jason A. Donenfeld" Date: Thu, 16 Aug 2018 12:09:07 -0700 Message-ID: Subject: Re: [PATCH android] config: fix wrong Peer endpoint string format To: gang.zhao.42@gmail.com Content-Type: text/plain; charset="UTF-8" Cc: WireGuard mailing list List-Id: Development discussion of WireGuard List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 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