1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Check Tox DNS protocol version, reject if not tox1

We only support tox1 for now, and soon we should tox3
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-11-05 20:48:46 +01:00
parent 7372fe5314
commit d158d27fc5
No known key found for this signature in database
GPG Key ID: 7E086DD661263264

View File

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