Skip to content

Commit

Permalink
Allow non-DNSSEC hosts
Browse files Browse the repository at this point in the history
Signed-off-by: Daniele Ricci <[email protected]>
  • Loading branch information
daniele-athome committed Sep 28, 2017
1 parent 18e9506 commit b459e0c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion app/src/main/java/org/kontalk/client/KontalkConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.kontalk.client;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.cert.Certificate;
Expand Down Expand Up @@ -91,9 +93,22 @@ private static XMPPTCPConnectionConfiguration buildConfiguration(String resource
XMPPTCPConnectionConfiguration.Builder builder =
XMPPTCPConnectionConfiguration.builder();

String host = server.getHost();
InetAddress inetAddress = null;
if (host != null) {
try {
inetAddress = InetAddress.getByName(host);
}
catch (UnknownHostException e) {
Log.w(TAG, "unable to resolve host " + host + ", will try again during connect", e);
}
}

builder
// connection parameters
.setHost(server.getHost())
.setHostAddress(inetAddress)
// try a last time through Smack
.setHost(inetAddress != null ? null : host)
.setPort(secure ? server.getSecurePort() : server.getPort())
.setXmppDomain(server.getNetwork())
.setResource(resource)
Expand Down

0 comments on commit b459e0c

Please sign in to comment.