aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/xmpp
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-06-25 21:17:32 +0200
committerChristian Schneppe <christian@pix-art.de>2019-06-25 21:47:19 +0200
commit1d8fa7e99dc1304ece611bff99d12f52981ab1f9 (patch)
tree91e3790c1ad84b5413238c74b2c09b080234a893 /src/main/java/de/pixart/messenger/xmpp
parent73c8feea13a526259ee5bb58e639e31ad781fd79 (diff)
Revert "Networkstack - let OS decide IPv4 or IPv6 (#267)"
This reverts commit e6a15597904019f68c02e6fd8f61fb6de0b13324. If there is IPv6 available but the server doesn't listen to it, the connection will not be established
Diffstat (limited to 'src/main/java/de/pixart/messenger/xmpp')
-rw-r--r--src/main/java/de/pixart/messenger/xmpp/XmppConnection.java31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
index 9a72203b7..3a7e41c9a 100644
--- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
+++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java
@@ -320,6 +320,16 @@ public class XmppConnection implements Runnable {
Log.e(Config.LOGTAG, account.getJid().asBareJid() + ": Resolver results were empty");
return;
}
+ final Resolver.Result storedBackupResult;
+ if (hardcoded) {
+ storedBackupResult = null;
+ } else {
+ storedBackupResult = mXmppConnectionService.databaseBackend.findResolverResult(domain);
+ if (storedBackupResult != null && !results.contains(storedBackupResult)) {
+ results.add(storedBackupResult);
+ Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": loaded backup resolver result from db: " + storedBackupResult);
+ }
+ }
for (Iterator<Resolver.Result> iterator = results.iterator(); iterator.hasNext(); ) {
final Resolver.Result result = iterator.next();
if (Thread.currentThread().isInterrupted()) {
@@ -331,10 +341,18 @@ public class XmppConnection implements Runnable {
features.encryptionEnabled = result.isDirectTls();
verifiedHostname = result.isAuthenticated() ? result.getHostname().toString() : null;
Log.d(Config.LOGTAG, "verified hostname " + verifiedHostname);
- final InetSocketAddress addr = new InetSocketAddress(IDN.toASCII(result.getHostname().toString()), result.getPort());
- Log.d(Config.LOGTAG, account.getJid().asBareJid().toString()
- + ": using values from resolver "
- + result.getHostname().toString() + ":" + result.getPort() + " tls: " + features.encryptionEnabled);
+ final InetSocketAddress addr;
+ if (result.getIp() != null) {
+ addr = new InetSocketAddress(result.getIp(), result.getPort());
+ Log.d(Config.LOGTAG, account.getJid().asBareJid().toString()
+ + ": using values from resolver " + (result.getHostname() == null ? "" : result.getHostname().toString()
+ + "/") + result.getIp().getHostAddress() + ":" + result.getPort() + " tls: " + features.encryptionEnabled);
+ } else {
+ addr = new InetSocketAddress(IDN.toASCII(result.getHostname().toString()), result.getPort());
+ Log.d(Config.LOGTAG, account.getJid().asBareJid().toString()
+ + ": using values from resolver "
+ + result.getHostname().toString() + ":" + result.getPort() + " tls: " + features.encryptionEnabled);
+ }
if (!features.encryptionEnabled) {
localSocket = new Socket();
@@ -362,6 +380,9 @@ public class XmppConnection implements Runnable {
localSocket.setSoTimeout(Config.SOCKET_TIMEOUT * 1000);
if (startXmpp(localSocket)) {
localSocket.setSoTimeout(0); //reset to 0; once the connection is established we don’t want this
+ if (!hardcoded && !result.equals(storedBackupResult)) {
+ mXmppConnectionService.databaseBackend.saveResolverResult(domain, result);
+ }
break; // successfully connected to server that speaks xmpp
} else {
FileBackend.close(localSocket);
@@ -1969,4 +1990,4 @@ public class XmppConnection implements Runnable {
return hasDiscoFeature(account.getJid().asBareJid(), Namespace.STANZA_IDS);
}
}
-}
+} \ No newline at end of file