From 760c0ea9d9451dec42f8d24e36db23aa0c8532d6 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 7 Jun 2023 11:37:26 +0200 Subject: [PATCH] fix dht-node to handle pubkey as 32 bit buffer --- dht-node/src/dht_node/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dht-node/src/dht_node/index.ts b/dht-node/src/dht_node/index.ts index 36291904a..7e326c33f 100644 --- a/dht-node/src/dht_node/index.ts +++ b/dht-node/src/dht_node/index.ts @@ -94,7 +94,7 @@ export const startDHT = async (topic: string): Promise => { const variables = { apiVersion: recApiVersion.api, endPoint: recApiVersion.url, - publicKey: socket.remotePublicKey.toString('hex'), + publicKey: socket.remotePublicKey, lastAnnouncedAt: new Date(), } logger.debug(`upsert with variables=${JSON.stringify(variables)}`) @@ -195,14 +195,14 @@ async function writeFederatedHomeCommunityEntries(pubKey: string): Promise { // check for existing homeCommunity entry let homeCom = await DbCommunity.findOne({ foreign: false, - publicKey: Buffer.from(pubKey), + publicKey: Buffer.from(pubKey, 'hex'), }) if (!homeCom) { // check if a homecommunity with a different publicKey still exists @@ -225,7 +225,7 @@ async function writeHomeCommunityEntry(pubKey: string): Promise { } if (homeCom) { // simply update the existing entry, but it MUST keep the ID and UUID because of possible relations - homeCom.publicKey = Buffer.from(pubKey) + homeCom.publicKey = Buffer.from(pubKey, 'hex') homeCom.url = CONFIG.FEDERATION_COMMUNITY_URL + '/api/' homeCom.name = CONFIG.COMMUNITY_NAME homeCom.description = CONFIG.COMMUNITY_DESCRIPTION @@ -235,7 +235,7 @@ async function writeHomeCommunityEntry(pubKey: string): Promise { // insert a new homecommunity entry including a new ID and a new but ensured unique UUID homeCom = new DbCommunity() homeCom.foreign = false - homeCom.publicKey = Buffer.from(pubKey) + homeCom.publicKey = Buffer.from(pubKey, 'hex') homeCom.communityUuid = await newCommunityUuid() homeCom.url = CONFIG.FEDERATION_COMMUNITY_URL + '/api/' homeCom.name = CONFIG.COMMUNITY_NAME