PDA

View Full Version : How to read the content of DNS record?



ricardodovalle
6th July 2015, 20:09
I have multiples DNS record (MX, CNAME , TXT) and I would like to read the TXT record content.

Is it possible?
Is there any example?

Thanks.

anda_skoa
6th July 2015, 21:00
http://doc.qt.io/qt-5/qdnslookup.html#textRecords

Cheers,
_

ricardodovalle
6th July 2015, 23:22
Could you help me, please?

The lookup() function never emit finished() or error(), I tried using this code:



m_dns = new QDnsLookup(this);
connect(m_dns, SIGNAL(finished()), this, SLOT(onHandle()));

m_dns->setType(QDnsLookup::TXT);
m_dns->setName("uol.com.br");
m_dns->lookup();


void Update::onHandle()
{
if (m_dns->error() != QDnsLookup::NoError)
qDebug() << m_dns->error() << m_dns->errorString();

foreach (const QDnsServiceRecord &record, m_dns->serviceRecords()) {
qDebug() << "Name: " << record.name() << "Target: " << record.target();
}

emit handled();
}


Thanks any help,

jefftee
7th July 2015, 04:50
QDnsLookup appears to use a thread pool to perform its DNS lookup requests. Do you have an event loop running at the time you do the m_dns->lookup()?

Edit: Also, you said you're looking for TXT records, so your OnHandle slot should be looking at m_dns->textRecords(), not m_dns->serviceRecords(), correct?

ricardodovalle
7th July 2015, 15:00
Thank you very much! It is working with m_dns->textRecords()

jefftee
7th July 2015, 16:44
Glad its working for you, but I thought your issue was that the finished() signal was never fired? What did you change to get that working?