From d158d27fc53119fb1e744c844b2be105e18caac8 Mon Sep 17 00:00:00 2001 From: "Tux3 / Mlkj / !Lev.uXFMLA" Date: Wed, 5 Nov 2014 20:48:46 +0100 Subject: [PATCH] Check Tox DNS protocol version, reject if not tox1 We only support tox1 for now, and soon we should tox3 --- src/widget/form/addfriendform.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/widget/form/addfriendform.cpp b/src/widget/form/addfriendform.cpp index 9e1243eff..b80e3000d 100644 --- a/src/widget/form/addfriendform.cpp +++ b/src/widget/form/addfriendform.cpp @@ -110,7 +110,7 @@ void AddFriendForm::onSendTriggered() void AddFriendForm::handleDnsLookup() { - const QString idKeyWord("id="); + const QString idKeyWord("id="), verKeyWord("v="); if (dns.error() == QDnsLookup::NotFoundError) { showWarning(tr("This address does not exist","The DNS gives the Tox ID associated to toxme.se addresses")); @@ -134,6 +134,23 @@ void AddFriendForm::handleDnsLookup() } const QString entry(textRecordValues.first()); + + // Check toxdns protocol version, we only support tox1 for now + int verx = entry.indexOf(verKeyWord); + if (verx) { + verx += verKeyWord.size(); + int verend = entry.indexOf(';', verx); + if (verend) + { + QString ver = entry.mid(verx, verend); + if (ver != "tox1") + { + showWarning(tr("The version of Tox DNS used by this server is not supported", "Error with the DNS")); + return; + } + } + } + int idx = entry.indexOf(idKeyWord); if (idx < 0) { showWarning(tr("The DNS lookup does not contain any Tox ID", "Error with the DNS"));