Try on all addresses when using a VPN

pull/176/head
M66B 5 years ago
parent bcd56f8771
commit baa94dcece

@ -388,6 +388,7 @@ public class EmailService implements AutoCloseable {
InetAddress[] iaddrs = InetAddress.getAllByName(host); InetAddress[] iaddrs = InetAddress.getAllByName(host);
boolean ip4 = (main instanceof Inet4Address); boolean ip4 = (main instanceof Inet4Address);
boolean ip6 = (main instanceof Inet6Address); boolean ip6 = (main instanceof Inet6Address);
boolean vpn = ConnectionHelper.vpnActive(context);
boolean has4 = false; boolean has4 = false;
boolean has6 = false; boolean has6 = false;
@ -409,7 +410,8 @@ public class EmailService implements AutoCloseable {
EntityLog.log(context, "Address main=" + main + EntityLog.log(context, "Address main=" + main +
" count=" + iaddrs.length + " count=" + iaddrs.length +
" ip4=" + ip4 + "/" + has4 + " ip4=" + ip4 + "/" + has4 +
" ip6=" + ip6 + "/" + has6); " ip6=" + ip6 + "/" + has6 +
" vpn=" + vpn);
for (InetAddress iaddr : iaddrs) { for (InetAddress iaddr : iaddrs) {
EntityLog.log(context, "Address resolved=" + iaddr); EntityLog.log(context, "Address resolved=" + iaddr);
@ -417,6 +419,7 @@ public class EmailService implements AutoCloseable {
if (iaddr.equals(main)) if (iaddr.equals(main))
continue; continue;
if (!vpn) {
if (iaddr instanceof Inet4Address) { if (iaddr instanceof Inet4Address) {
if (ip4 || !has4) if (ip4 || !has4)
continue; continue;
@ -428,6 +431,7 @@ public class EmailService implements AutoCloseable {
continue; continue;
ip6 = true; ip6 = true;
} }
}
String prop = "mail." + protocol + ".connectiontimeout"; String prop = "mail." + protocol + ".connectiontimeout";
String timeout = properties.getProperty(prop); String timeout = properties.getProperty(prop);
@ -437,7 +441,7 @@ public class EmailService implements AutoCloseable {
_connect(iaddr.getHostAddress(), port, user, password, factory); _connect(iaddr.getHostAddress(), port, user, password, factory);
return; return;
} catch (MessagingException ex1) { } catch (MessagingException ex1) {
Log.w(ex1); EntityLog.log(context, "Fallback ex=" + ex.getMessage());
} finally { } finally {
if (timeout != null) if (timeout != null)
properties.put(prop, timeout); properties.put(prop, timeout);

Loading…
Cancel
Save