Skip to content
Permalink
Browse files

Merge PR #3268: Fix SRV port bugs in ServerResolver and ConnectDialog

This PR includes two fixes for SRV port issues.

The first fix is for ServerResolver.  The Qt 5 (SRV) version had a bug where resolved ServerResolverRecords would be created with `m_origPort`. In practice, this meant that Mumble would *always* use the port specified in the ConnectDialog record for the server. Typically, this would be 64738, the default port.

The second fix is somewhat related to the first. The ConnectDialog had a bug where it would use `ServerResolver::port()` instead of `ServerResolverRecord::port()` when constructing the list of resolved addresses for a ConnectDialog entry. Unfortunately, `ServerResolver::port()` is the "original port". That is, the port specified in the ConnectDialog entry. Once again, this meant that Mumble would display the wrong port to user: the one from the ConnectDialog entry instead of the resolved port. Typically, this would be the default port (64738).

Fixes #3267
  • Loading branch information...
mkrautz committed Nov 26, 2017
2 parents fba1d65 + 7acf687 commit 48f3eb94ee2c7b47c616c3ce846ed16463c52ce8
Showing with 50 additions and 2 deletions.
  1. +1 −1 src/ServerResolver_qt5.cpp
  2. +1 −1 src/mumble/ConnectDialog.cpp
  3. +48 −0 src/tests/TestServerResolver/TestServerResolver.cpp
@@ -98,7 +98,7 @@ void ServerResolverPrivate::hostResolved(QHostInfo hostInfo) {
}

qint64 priority = normalizeSrvPriority(record.priority(), record.weight());
m_resolved << ServerResolverRecord(m_origHostname, m_origPort, priority, addresses);
m_resolved << ServerResolverRecord(m_origHostname, record.port(), priority, addresses);
}

m_srvQueueRemain -= 1;
@@ -1645,7 +1645,7 @@ void ConnectDialog::lookedUp() {
QSet<ServerAddress> qs;
foreach (ServerResolverRecord record, sr->records()) {
foreach(const HostAddress &ha, record.addresses()) {
qs.insert(ServerAddress(ha, sr->port()));
qs.insert(ServerAddress(ha, record.port()));
}
}

@@ -25,6 +25,7 @@ class TestServerResolver : public QObject {
Q_OBJECT
private slots:
void simpleSrv();
void srvCustomPort();
void simpleA();
void simpleAAAA();
void simpleCNAME();
@@ -77,6 +78,53 @@ void TestServerResolver::simpleSrv() {
QVERIFY(hasipv4 || hasipv6);
}

void TestServerResolver::srvCustomPort() {
#ifdef USE_NO_SRV
return;
#endif

ServerResolver r;
QSignalSpy spy(&r, SIGNAL(resolved()));

QString hostname = QString::fromLatin1("customport.serverresolver.mumble.info");
quint16 customPort = 36001;
r.resolve(hostname, 64738);

signalSpyWait(spy);

QCOMPARE(spy.count(), 1);

QList<ServerResolverRecord> records = r.records();
QCOMPARE(records.size(), 1);

ServerResolverRecord record = records.at(0);
QCOMPARE(record.hostname(), hostname);
QCOMPARE(record.port(), customPort);
// Allow 1 or 2 results. The answer depends on whether
// the system supports IPv4, IPv6, or both.
QVERIFY(record.addresses().size() == 1 || record.addresses().size() == 2);
QCOMPARE(record.priority(), 65545); // priority=1, weight=10 -> 1 * 65535 + 10

bool hasipv4 = false;
bool hasipv6 = false;

HostAddress v4(QHostAddress(QLatin1String("127.0.0.1")));
HostAddress v6(QHostAddress(QLatin1String("::1")));

foreach (HostAddress ha, record.addresses()) {
if (ha == v4) {
hasipv4 = true;
}
if (ha == v6) {
hasipv6 = true;
}
}

// Require either an IPv4 match, or an IPv6 match.
QVERIFY(hasipv4 || hasipv6);
}


void TestServerResolver::simpleCNAME() {
ServerResolver r;
QSignalSpy spy(&r, SIGNAL(resolved()));

0 comments on commit 48f3eb9

Please sign in to comment.
You can’t perform that action at this time.