mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Improve DHT bootsraping reliability
Don't try to spam boostrap nodes, if we've tried enough nodes and none of them worked, chances are our connection is just a little slow, so wait some more before trying even more nodes or we might never see the end of it. May help with #221
This commit is contained in:
parent
f97729261a
commit
53c07fc4a7
17
core.cpp
17
core.cpp
|
@ -738,14 +738,23 @@ void Core::onFileTransferFinished(ToxFile file)
|
|||
|
||||
void Core::bootstrapDht()
|
||||
{
|
||||
qDebug() << "Core: Bootstraping DHT";
|
||||
const Settings& s = Settings::getInstance();
|
||||
QList<Settings::DhtServer> 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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
core.h
2
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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user