ServerResolver: fix bug where ServerResolver_qt5 would always pass on the original port given to the resolver.

Instead of using the port from the QDnsServiceRecord, the
srvResolved() slot used m_origPort. Oops.

Fixes mumble-voip/mumble#3267
This commit is contained in:
Mikkel Krautz 2017-11-26 12:33:38 +01:00
parent fba1d65b3e
commit 04a8a5db81
2 changed files with 49 additions and 1 deletions

View File

@ -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;

View File

@ -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()));