aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/xmpp/XmppConnection.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-07 06:52:09 +0100
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-07 06:52:09 +0100
commit86dbb2f411c28a5eaae207caf1e6bcd1e56503b0 (patch)
treec85031c36881c0fd92567f90c78571468b684301 /src/de/gultsch/chat/xmpp/XmppConnection.java
parentcda1c2c3a12b4c18f13771dd4b58aab6e465176b (diff)
wrote the scariest code ever to fetch srv records from dns. todo use real dns servers and dont hard code 8.8.8.8
Diffstat (limited to '')
-rw-r--r--src/de/gultsch/chat/xmpp/XmppConnection.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/de/gultsch/chat/xmpp/XmppConnection.java b/src/de/gultsch/chat/xmpp/XmppConnection.java
index c105bbb4..d7443fc4 100644
--- a/src/de/gultsch/chat/xmpp/XmppConnection.java
+++ b/src/de/gultsch/chat/xmpp/XmppConnection.java
@@ -14,9 +14,11 @@ import javax.net.ssl.SSLSocketFactory;
import org.xmlpull.v1.XmlPullParserException;
+import android.os.Bundle;
import android.os.PowerManager;
import android.util.Log;
import de.gultsch.chat.entities.Account;
+import de.gultsch.chat.utils.DNSHelper;
import de.gultsch.chat.utils.SASL;
import de.gultsch.chat.xml.Element;
import de.gultsch.chat.xml.Tag;
@@ -64,7 +66,15 @@ public class XmppConnection implements Runnable {
protected void connect() {
try {
- socket = new Socket(account.getServer(), 5222);
+ Bundle namePort = DNSHelper.getSRVRecord(account.getServer());
+ String srvRecordServer = namePort.getString("name");
+ int srvRecordPort = namePort.getInt("port");
+ if (srvRecordServer!=null) {
+ Log.d(LOGTAG,account.getJid()+": using values from dns "+srvRecordServer+":"+srvRecordPort);
+ socket = new Socket(srvRecordServer,srvRecordPort);
+ } else {
+ socket = new Socket(account.getServer(), 5222);
+ }
OutputStream out = socket.getOutputStream();
tagWriter.setOutputStream(out);
InputStream in = socket.getInputStream();
@@ -91,6 +101,7 @@ public class XmppConnection implements Runnable {
}
return;
} catch (IOException e) {
+ Log.d(LOGTAG,"bla "+e.getMessage());
if (shouldConnect) {
Log.d(LOGTAG,account.getJid()+": connection lost");
account.setStatus(Account.STATUS_OFFLINE);