diff --git a/core.cpp b/core.cpp index 9c76975b0..50f274ef8 100644 --- a/core.cpp +++ b/core.cpp @@ -738,14 +738,23 @@ void Core::onFileTransferFinished(ToxFile file) void Core::bootstrapDht() { - qDebug() << "Core: Bootstraping DHT"; const Settings& s = Settings::getInstance(); QList dhtServerList = s.getDhtServerList(); int listSize = dhtServerList.size(); - static int j = qrand() % listSize; + static int j = qrand() % listSize, n=0; + + // We couldn't connect after trying 6 different nodes, let's try something else + if (n>3) + { + qDebug() << "Core: We're having trouble connecting to the DHT, slowing down"; + bootstrapTimer->setInterval(TOX_BOOTSTRAP_INTERVAL*(n-1)); + } + else + qDebug() << "Core: Connecting to the DHT ..."; + int i=0; - while (i<5) + while (i < (2 - (n>3))) { const Settings::DhtServer& dhtServer = dhtServerList[j % listSize]; if (tox_bootstrap_from_address(tox, dhtServer.address.toLatin1().data(), @@ -755,8 +764,10 @@ void Core::bootstrapDht() else qDebug() << "Core: Error bootstraping from "+dhtServer.name; + tox_do(tox); j++; i++; + n++; } } diff --git a/core.h b/core.h index d94f65473..130558df4 100644 --- a/core.h +++ b/core.h @@ -36,7 +36,7 @@ #define GROUPCHAT_MAX_SIZE 32 #define TOX_SAVE_INTERVAL 30*1000 #define TOX_FILE_INTERVAL 1 -#define TOX_BOOTSTRAP_INTERVAL 10*1000 +#define TOX_BOOTSTRAP_INTERVAL 5*1000 #define TOXAV_RINGING_TIME 15 // TODO: Put that in the settings diff --git a/res/settings.ini b/res/settings.ini index 94878406f..2a051ab94 100644 --- a/res/settings.ini +++ b/res/settings.ini @@ -1,5 +1,5 @@ [DHT%20Server] -dhtServerList\size=16 +dhtServerList\size=15 dhtServerList\1\name=stqism dhtServerList\1\userId=951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F dhtServerList\1\address=192.254.75.98