Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
feat: remove old boostrap nodes code
Browse files Browse the repository at this point in the history
This commit replaces the bootstrap node list in the qtox.ini file with
the boostrapnodeupdater class.
  • Loading branch information
sudden6 committed Mar 1, 2019
1 parent 1f2bdf3 commit acef759
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 237 deletions.
1 change: 0 additions & 1 deletion res.qrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<RCC>
<qresource prefix="/conf">
<file alias="settings.ini">res/settings.ini</file>
<file alias="nodes.json">res/nodes.json</file>
</qresource>
<qresource prefix="/font">
Expand Down
150 changes: 0 additions & 150 deletions res/settings.ini

This file was deleted.

8 changes: 5 additions & 3 deletions src/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
#include "core.h"
#include "corefile.h"
#include "src/core/coreav.h"
#include "src/core/dhtserver.h"
#include "src/core/icoresettings.h"
#include "src/core/toxlogger.h"
#include "src/core/toxoptions.h"
#include "src/core/toxstring.h"
#include "src/model/groupinvite.h"
#include "src/nexus.h"
#include "src/net/bootstrapnodeupdater.h"
#include "src/persistence/profile.h"
#include "src/util/strongtype.h"

Expand Down Expand Up @@ -279,9 +281,6 @@ ToxCorePtr Core::makeToxCore(const QByteArray& savedata, const ICoreSettings* co
return {};
}

// provide a list of bootstrap nodes
core->bootstrapNodes = settings->getDhtServerList();

// tox should be valid by now
assert(core->tox != nullptr);

Expand Down Expand Up @@ -423,6 +422,9 @@ bool Core::checkConnection()
void Core::bootstrapDht()
{
ASSERT_CORE_THREAD;

QList<DhtServer> bootstrapNodes = BootstrapNodeUpdater::loadDefaultBootstrapNodes();

int listSize = bootstrapNodes.size();
if (!listSize) {
qWarning() << "no bootstrap list?!?";
Expand Down
2 changes: 0 additions & 2 deletions src/core/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "toxfile.h"
#include "toxid.h"

#include "src/core/dhtserver.h"
#include "src/util/strongtype.h"
#include <tox/tox.h>

Expand Down Expand Up @@ -277,7 +276,6 @@ private slots:
std::unique_ptr<QMutex> coreLoopLock = nullptr;

std::unique_ptr<QThread> coreThread = nullptr;
QList<DhtServer> bootstrapNodes{};

friend class Audio; ///< Audio can access our calls directly to reduce latency
friend class CoreFile; ///< CoreFile can access tox* and emit our signals
Expand Down
5 changes: 0 additions & 5 deletions src/core/icoresettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define I_CORE_SETTINGS_H

#include "src/model/interface.h"
#include "src/core/dhtserver.h"

#include <QList>
#include <QNetworkProxy>
Expand Down Expand Up @@ -36,9 +35,6 @@ class ICoreSettings {
virtual quint16 getProxyPort() const = 0;
virtual void setProxyPort(quint16 port) = 0;

virtual const QList<DhtServer>& getDhtServerList() const = 0;
virtual void setDhtServerList(const QList<DhtServer>& servers) = 0;

virtual QNetworkProxy getProxy() const = 0;

DECLARE_SIGNAL(enableIPv6Changed, bool enabled);
Expand All @@ -47,7 +43,6 @@ class ICoreSettings {
DECLARE_SIGNAL(proxyTypeChanged, ICoreSettings::ProxyType type);
DECLARE_SIGNAL(proxyAddressChanged, const QString& address);
DECLARE_SIGNAL(proxyPortChanged, quint16 port);
DECLARE_SIGNAL(dhtServerListChanged, const QList<DhtServer>& servers);
};

#endif // I_CORE_SETTINGS_H
71 changes: 0 additions & 71 deletions src/persistence/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,6 @@ void Settings::loadGlobal()
}
s.endGroup();

s.beginGroup("DHT Server");
{
if (s.value("useCustomList").toBool()) {
useCustomDhtList = true;
qDebug() << "Using custom bootstrap nodes list";
int serverListSize = s.beginReadArray("dhtServerList");
for (int i = 0; i < serverListSize; i++) {
s.setArrayIndex(i);
DhtServer server;
server.name = s.value("name").toString();
server.userId = s.value("userId").toString();
server.address = s.value("address").toString();
server.port = static_cast<quint16>(s.value("port").toUInt());
dhtServerList << server;
}
s.endArray();
} else {
useCustomDhtList = false;
}
}
s.endGroup();

s.beginGroup("General");
{
translation = s.value("translation", "en").toString();
Expand Down Expand Up @@ -291,25 +269,6 @@ void Settings::loadGlobal()
}
s.endGroup();

// Read the embedded DHT bootstrap nodes list if needed
if (dhtServerList.isEmpty()) {
QSettings rcs(":/conf/settings.ini", QSettings::IniFormat);
rcs.setIniCodec("UTF-8");
rcs.beginGroup("DHT Server");
int serverListSize = rcs.beginReadArray("dhtServerList");
for (int i = 0; i < serverListSize; i++) {
rcs.setArrayIndex(i);
DhtServer server;
server.name = rcs.value("name").toString();
server.userId = rcs.value("userId").toString();
server.address = rcs.value("address").toString();
server.port = static_cast<quint16>(rcs.value("port").toUInt());
dhtServerList << server;
}
rcs.endArray();
rcs.endGroup();
}

loaded = true;
}

Expand Down Expand Up @@ -474,21 +433,6 @@ void Settings::saveGlobal()
}
s.endGroup();

s.beginGroup("DHT Server");
{
s.setValue("useCustomList", useCustomDhtList);
s.beginWriteArray("dhtServerList", dhtServerList.size());
for (int i = 0; i < dhtServerList.size(); i++) {
s.setArrayIndex(i);
s.setValue("name", dhtServerList[i].name);
s.setValue("userId", dhtServerList[i].userId);
s.setValue("address", dhtServerList[i].address);
s.setValue("port", dhtServerList[i].port);
}
s.endArray();
}
s.endGroup();

s.beginGroup("General");
{
s.setValue("translation", translation);
Expand Down Expand Up @@ -813,21 +757,6 @@ QString Settings::getAppCacheDirPath() const
#endif
}

const QList<DhtServer>& Settings::getDhtServerList() const
{
QMutexLocker locker{&bigLock};
return dhtServerList;
}

void Settings::setDhtServerList(const QList<DhtServer>& servers)
{
QMutexLocker locker{&bigLock};

if (servers != dhtServerList) {
dhtServerList = servers;
emit dhtServerListChanged(dhtServerList);
}
}
bool Settings::getEnableTestSound() const
{
QMutexLocker locker{&bigLock};
Expand Down
5 changes: 0 additions & 5 deletions src/persistence/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,6 @@ public slots:
bool getAutoSaveEnabled() const;

// ICoreSettings
const QList<DhtServer>& getDhtServerList() const override;
void setDhtServerList(const QList<DhtServer>& servers) override;

bool getEnableIPv6() const override;
void setEnableIPv6(bool enabled) override;

Expand All @@ -308,7 +305,6 @@ public slots:
SIGNAL_IMPL(Settings, proxyTypeChanged, ICoreSettings::ProxyType type)
SIGNAL_IMPL(Settings, proxyAddressChanged, const QString& address)
SIGNAL_IMPL(Settings, proxyPortChanged, quint16 port)
SIGNAL_IMPL(Settings, dhtServerListChanged, const QList<DhtServer>& servers)

bool getEnableLogging() const;
void setEnableLogging(bool newValue);
Expand Down Expand Up @@ -587,7 +583,6 @@ public slots:
bool loaded;

bool useCustomDhtList;
QList<DhtServer> dhtServerList;
int dhtServerId;
bool dontShowDhtDialog;

Expand Down

0 comments on commit acef759

Please sign in to comment.