From 645c843161661af45f2208b650476bf29fa5d1ff Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 10 Apr 2019 18:54:59 +0200 Subject: [PATCH] Fixed IPv6 local host address --- app/src/main/java/eu/faircode/email/ServiceSend.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSend.java b/app/src/main/java/eu/faircode/email/ServiceSend.java index 210be0a9e4..f129ab7a73 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSend.java +++ b/app/src/main/java/eu/faircode/email/ServiceSend.java @@ -270,8 +270,11 @@ public class ServiceSend extends LifecycleService { InetAddress addr = InetAddress.getByName(ident.host); if (addr instanceof Inet4Address) haddr = "[" + Inet4Address.getLocalHost().getHostAddress() + "]"; - else - haddr = "[IPv6:" + Inet6Address.getLocalHost().getHostAddress() + "]"; + else { + // Inet6Address.getLocalHost() will return the IPv6 local host + byte[] LOOPBACK = new byte[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; + haddr = "[IPv6:" + Inet6Address.getByAddress("ip6-localhost", LOOPBACK, 0).getHostAddress() + "]"; + } } else haddr = ident.host;