本文整理汇总了C++中QDnsLookup::mailExchangeRecords方法的典型用法代码示例。如果您正苦于以下问题:C++ QDnsLookup::mailExchangeRecords方法的具体用法?C++ QDnsLookup::mailExchangeRecords怎么用?C++ QDnsLookup::mailExchangeRecords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDnsLookup
的用法示例。
在下文中一共展示了QDnsLookup::mailExchangeRecords方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
QList<QDnsMailExchangeRecord> QDnsLookupProto::mailExchangeRecords() const
{
QDnsLookup *item = qscriptvalue_cast<QDnsLookup*>(thisObject());
if (item)
return item->mailExchangeRecords();
return QList<QDnsMailExchangeRecord>();
}
示例2: lookup
void tst_QDnsLookup::lookup()
{
QFETCH(int, type);
QFETCH(QString, domain);
QFETCH(int, error);
QFETCH(QString, cname);
QFETCH(QString, host);
QFETCH(QString, mx);
QFETCH(QString, ns);
QFETCH(QString, ptr);
QFETCH(QString, srv);
QFETCH(QString, txt);
// transform the inputs
domain = domainName(domain);
cname = domainName(cname);
ns = domainNameList(ns);
ptr = domainNameList(ptr);
// SRV and MX have reply entries that can change order
// and we can't sort
QStringList mx_alternatives = domainNameListAlternatives(mx);
QStringList srv_alternatives = domainNameListAlternatives(srv);
QDnsLookup lookup;
lookup.setType(static_cast<QDnsLookup::Type>(type));
lookup.setName(domain);
lookup.lookup();
QVERIFY(waitForDone(&lookup));
QVERIFY(lookup.isFinished());
#if defined(Q_OS_ANDROID)
if (lookup.errorString() == QStringLiteral("Not yet supported on Android"))
QEXPECT_FAIL("", "Not yet supported on Android", Abort);
#endif
QVERIFY2(int(lookup.error()) == error,
msgDnsLookup(lookup.error(), error, domain, cname, host, srv, mx, ns, ptr, lookup.errorString()));
if (error == QDnsLookup::NoError)
QVERIFY(lookup.errorString().isEmpty());
QCOMPARE(int(lookup.type()), type);
QCOMPARE(lookup.name(), domain);
// canonical names
if (!cname.isEmpty()) {
QVERIFY(!lookup.canonicalNameRecords().isEmpty());
const QDnsDomainNameRecord cnameRecord = lookup.canonicalNameRecords().first();
QCOMPARE(cnameRecord.name(), domain);
QCOMPARE(cnameRecord.value(), cname);
} else {
QVERIFY(lookup.canonicalNameRecords().isEmpty());
}
// host addresses
const QString hostName = cname.isEmpty() ? domain : cname;
QStringList addresses;
foreach (const QDnsHostAddressRecord &record, lookup.hostAddressRecords()) {
//reply may include A & AAAA records for nameservers, ignore them and only look at records matching the query
if (record.name() == hostName)
addresses << record.value().toString().toLower();
}
addresses.sort();
QCOMPARE(addresses.join(';'), host);
// mail exchanges
QStringList mailExchanges;
foreach (const QDnsMailExchangeRecord &record, lookup.mailExchangeRecords()) {
QCOMPARE(record.name(), domain);
mailExchanges << QString("%1 %2").arg(QString::number(record.preference()), record.exchange());
}
QVERIFY2(mx_alternatives.contains(mailExchanges.join(';')),
qPrintable("Actual: " + mailExchanges.join(';') + "\nExpected one of:\n" + mx_alternatives.join('\n')));
// name servers
QStringList nameServers;
foreach (const QDnsDomainNameRecord &record, lookup.nameServerRecords()) {
//reply may include NS records for authoritative nameservers, ignore them and only look at records matching the query
if (record.name() == domain)
nameServers << record.value();
}
nameServers.sort();
QCOMPARE(nameServers.join(';'), ns);
// pointers
if (!ptr.isEmpty()) {
QVERIFY(!lookup.pointerRecords().isEmpty());
const QDnsDomainNameRecord ptrRecord = lookup.pointerRecords().first();
QCOMPARE(ptrRecord.name(), domain);
QCOMPARE(ptrRecord.value(), ptr);
} else {
QVERIFY(lookup.pointerRecords().isEmpty());
}
// services
QStringList services;
foreach (const QDnsServiceRecord &record, lookup.serviceRecords()) {
QCOMPARE(record.name(), domain);
services << QString("%1 %2 %3 %4").arg(
QString::number(record.priority()),
QString::number(record.weight()),
//.........这里部分代码省略.........
示例3: lookup
void tst_QDnsLookup::lookup()
{
QFETCH(int, type);
QFETCH(QString, domain);
QFETCH(int, error);
QFETCH(QString, cname);
QFETCH(QString, host);
QFETCH(QString, mx);
QFETCH(QString, ns);
QFETCH(QString, ptr);
QFETCH(QString, srv);
QFETCH(QByteArray, txt);
// transform the inputs
domain = domainName(domain);
cname = domainName(cname);
mx = domainNameList(mx);
ns = domainNameList(ns);
ptr = domainNameList(ptr);
srv = domainNameList(srv);
QDnsLookup lookup;
lookup.setType(static_cast<QDnsLookup::Type>(type));
lookup.setName(domain);
lookup.lookup();
QVERIFY(waitForDone(&lookup));
QVERIFY(lookup.isFinished());
QVERIFY2(int(lookup.error()) == error, qPrintable(lookup.errorString()));
if (error == QDnsLookup::NoError)
QVERIFY(lookup.errorString().isEmpty());
QCOMPARE(int(lookup.type()), type);
QCOMPARE(lookup.name(), domain);
// canonical names
if (!cname.isEmpty()) {
QVERIFY(!lookup.canonicalNameRecords().isEmpty());
const QDnsDomainNameRecord cnameRecord = lookup.canonicalNameRecords().first();
QCOMPARE(cnameRecord.name(), domain);
QCOMPARE(cnameRecord.value(), cname);
} else {
QVERIFY(lookup.canonicalNameRecords().isEmpty());
}
// host addresses
const QString hostName = cname.isEmpty() ? domain : cname;
QStringList addresses;
foreach (const QDnsHostAddressRecord &record, lookup.hostAddressRecords()) {
//reply may include A & AAAA records for nameservers, ignore them and only look at records matching the query
if (record.name() == hostName)
addresses << record.value().toString().toLower();
}
addresses.sort();
QCOMPARE(addresses.join(';'), host);
// mail exchanges
QStringList mailExchanges;
foreach (const QDnsMailExchangeRecord &record, lookup.mailExchangeRecords()) {
QCOMPARE(record.name(), domain);
mailExchanges << QString("%1 %2").arg(QString::number(record.preference()), record.exchange());
}
QCOMPARE(mailExchanges.join(';'), mx);
// name servers
QStringList nameServers;
foreach (const QDnsDomainNameRecord &record, lookup.nameServerRecords()) {
//reply may include NS records for authoritative nameservers, ignore them and only look at records matching the query
if (record.name() == domain)
nameServers << record.value();
}
nameServers.sort();
QCOMPARE(nameServers.join(';'), ns);
// pointers
if (!ptr.isEmpty()) {
QVERIFY(!lookup.pointerRecords().isEmpty());
const QDnsDomainNameRecord ptrRecord = lookup.pointerRecords().first();
QCOMPARE(ptrRecord.name(), domain);
QCOMPARE(ptrRecord.value(), ptr);
} else {
QVERIFY(lookup.pointerRecords().isEmpty());
}
// services
QStringList services;
foreach (const QDnsServiceRecord &record, lookup.serviceRecords()) {
QCOMPARE(record.name(), domain);
services << QString("%1 %2 %3 %4").arg(
QString::number(record.priority()),
QString::number(record.weight()),
QString::number(record.port()),
record.target());
}
QCOMPARE(services.join(';'), srv);
// text
if (!txt.isEmpty()) {
QVERIFY(!lookup.textRecords().isEmpty());
const QDnsTextRecord firstRecord = lookup.textRecords().first();
QCOMPARE(firstRecord.name(), domain);
QCOMPARE(firstRecord.values().size(), 1);
//.........这里部分代码省略.........