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

fix(core): avoid logging which bootstrap node is being connected to

Errors are parsed and printed, but which specific node is being connected to
isn't very relevant to any errors that would occur, and the nodes list is
already updated to prune offline nodes based on nodes.tox.chat periodically.
This provides some extra privacy about which connections are being made,
even though the bootstrap nodes are already public.
This commit is contained in:
Anthony Bilinski 2019-10-07 23:33:55 -07:00
parent fe9d83d881
commit 731a49854a
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C

View File

@ -64,6 +64,30 @@ bool LogConferenceTitleError(TOX_ERR_CONFERENCE_TITLE error)
return error;
}
bool parseToxErrBootstrap(Tox_Err_Bootstrap error)
{
switch(error) {
case TOX_ERR_BOOTSTRAP_OK:
return true;
case TOX_ERR_BOOTSTRAP_NULL:
qCritical() << "null argument when not expected";
return false;
case TOX_ERR_BOOTSTRAP_BAD_HOST:
qCritical() << "Could not resolve hostname, or invalid IP address";
return false;
case TOX_ERR_BOOTSTRAP_BAD_PORT:
qCritical() << "out of range port";
return false;
default:
qCritical() << "Unknown Tox_Err_bootstrap error code:" << error;
return false;
}
}
bool parseFriendSendMessageError(Tox_Err_Friend_Send_Message error)
{
switch (error) {
@ -448,21 +472,19 @@ void Core::bootstrapDht()
QString dhtServerAddress = dhtServer.address.toLatin1();
QString port = QString::number(dhtServer.port);
QString name = dhtServer.name;
qDebug() << QString("Connecting to %1:%2 (%3)").arg(dhtServerAddress, port, name);
qDebug() << QString("Connecting to a bootstrap node...");
QByteArray address = dhtServer.address.toLatin1();
// TODO: constucting the pk via ToxId is a workaround
ToxPk pk = ToxId{dhtServer.userId}.getPublicKey();
const uint8_t* pkPtr = pk.getData();
if (!tox_bootstrap(tox.get(), address.constData(), dhtServer.port, pkPtr, nullptr)) {
qDebug() << "Error bootstrapping from " + dhtServer.name;
}
Tox_Err_Bootstrap error;
tox_bootstrap(tox.get(), address.constData(), dhtServer.port, pkPtr, &error);
parseToxErrBootstrap(error);
if (!tox_add_tcp_relay(tox.get(), address.constData(), dhtServer.port, pkPtr, nullptr)) {
qDebug() << "Error adding TCP relay from " + dhtServer.name;
}
tox_add_tcp_relay(tox.get(), address.constData(), dhtServer.port, pkPtr, &error);
parseToxErrBootstrap(error);
++j;
++i;