aboutsummaryrefslogtreecommitdiff
path: root/connectionprivate.cpp
diff options
context:
space:
mode:
authorFelix Rohrbach <fxrh@gmx.de>2016-05-01 21:38:13 +0200
committerFelix Rohrbach <fxrh@gmx.de>2016-05-01 21:38:13 +0200
commit22a675a55ae2dac33a680531f4003fbfeb24ec39 (patch)
tree3c7e575cd64aea4fdcbd78a936f1913532105fb4 /connectionprivate.cpp
parent00a73167ca455370868f1f82257420f0cb399a15 (diff)
parentaa8b077499653b6ebf2d78136c75c801e6f99c29 (diff)
downloadlibquotient-22a675a55ae2dac33a680531f4003fbfeb24ec39.tar.gz
libquotient-22a675a55ae2dac33a680531f4003fbfeb24ec39.zip
Merge pull request #3 from davidar/master
Resolve Matrix SRV records.
Diffstat (limited to 'connectionprivate.cpp')
-rw-r--r--connectionprivate.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/connectionprivate.cpp b/connectionprivate.cpp
index 90733ed0..50fd1b0c 100644
--- a/connectionprivate.cpp
+++ b/connectionprivate.cpp
@@ -31,6 +31,7 @@
#include "events/roommemberevent.h"
#include <QtCore/QDebug>
+#include <QtNetwork/QDnsLookup>
using namespace QMatrixClient;
@@ -46,6 +47,32 @@ ConnectionPrivate::~ConnectionPrivate()
delete data;
}
+void ConnectionPrivate::resolveServer(QString domain)
+{
+ // Find the Matrix server for the given domain.
+ QDnsLookup* dns = new QDnsLookup();
+ dns->setType(QDnsLookup::SRV);
+ dns->setName("_matrix._tcp." + domain);
+
+ connect(dns, &QDnsLookup::finished, [this,dns]() {
+ // Check the lookup succeeded.
+ if (dns->error() != QDnsLookup::NoError ||
+ dns->serviceRecords().isEmpty()) {
+ emit q->resolveError("DNS lookup failed");
+ dns->deleteLater();
+ return;
+ }
+
+ // Handle the results.
+ QDnsServiceRecord record = dns->serviceRecords().first();
+ data->setHost(record.target());
+ data->setPort(record.port());
+ emit q->resolved();
+ dns->deleteLater();
+ });
+ dns->lookup();
+}
+
void ConnectionPrivate::processState(State* state)
{
QString roomId = state->event()->roomId();
@@ -175,4 +202,4 @@ void ConnectionPrivate::gotRoomMembers(KJob* job)
if( membersJob->error() == BaseJob::NetworkError )
emit q->connectionError( membersJob->errorString() );
}
-} \ No newline at end of file
+}