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

refactor(bootstrap): Store public key as ToxPk rather than QString

This commit is contained in:
Anthony Bilinski 2022-02-15 14:37:43 -08:00
parent e7e30ada8c
commit 7aa8d7178e
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
4 changed files with 9 additions and 6 deletions

View File

@ -837,8 +837,7 @@ void Core::bootstrapDht()
address = dhtServer.ipv4.toLatin1();
}
ToxPk pk{dhtServer.userId};
const uint8_t* pkPtr = pk.getData();
const uint8_t* pkPtr = dhtServer.publicKey.getData();
Tox_Err_Bootstrap error;
if (dhtServer.statusUdp) {

View File

@ -32,7 +32,7 @@ bool DhtServer::operator==(const DhtServer& other) const
&& ipv4 == other.ipv4
&& ipv6 == other.ipv6
&& maintainer == other.maintainer
&& userId == other.userId
&& publicKey == other.publicKey
&& udpPort == other.udpPort
&& tcpPorts == other.tcpPorts);
}

View File

@ -19,6 +19,8 @@
#pragma once
#include "toxpk.h"
#include <QString>
#include <vector>
@ -29,7 +31,7 @@ struct DhtServer
QString ipv4;
QString ipv6;
QString maintainer;
QString userId;
ToxPk publicKey;
quint16 udpPort;
std::vector<uint16_t> tcpPorts;

View File

@ -20,6 +20,8 @@
#include "bootstrapnodeupdater.h"
#include "src/persistence/paths.h"
#include "src/core/toxpk.h"
#include "src/core/toxid.h"
#include <QDirIterator>
#include <QFile>
@ -120,7 +122,7 @@ void jsonNodeToDhtServer(const QJsonObject& node, QList<DhtServer>& outList)
server.statusUdp = true;
server.statusTcp = status_tcp;
server.tcpPorts = tcp_ports;
server.userId = public_key;
server.publicKey = ToxPk{public_key};
server.udpPort = udp_port_u16;
server.maintainer = maintainer;
server.ipv4 = ipv4_address;
@ -182,7 +184,7 @@ QByteArray serialize(QList<DhtServer> nodes)
nodeJson.insert(NodeFields::status_tcp, node.statusTcp);
nodeJson.insert(NodeFields::ipv4, node.ipv4);
nodeJson.insert(NodeFields::ipv6, node.ipv6);
nodeJson.insert(NodeFields::public_key, node.userId);
nodeJson.insert(NodeFields::public_key, node.publicKey.toString());
nodeJson.insert(NodeFields::udp_port, node.udpPort);
nodeJson.insert(NodeFields::maintainer, node.maintainer);