From 464b9ae05f7ed9ceed09365ea89cd74501c742e2 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Mon, 14 Mar 2022 15:08:08 +0200 Subject: [PATCH] fix: pinner logging --- packages/concordia-pinner/src/app.js | 8 +++++--- packages/concordia-pinner/src/utils/ipfsUtils.js | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/concordia-pinner/src/app.js b/packages/concordia-pinner/src/app.js index 9f32d22..f381773 100644 --- a/packages/concordia-pinner/src/app.js +++ b/packages/concordia-pinner/src/app.js @@ -22,8 +22,10 @@ const responseBody = { getResolvedRendezvousMultiaddress().then((multiaddress) => { const { address, port } = multiaddress.nodeAddress(); - const rendezvousUrl = `http://${address}:${port}`; - logger.info(`Resolved rendezvous URL to ${rendezvousUrl}`); + let rendezvousUrl = `${address}:${port}`; + if (port !== 443) rendezvousUrl = `http://${rendezvousUrl}`; + else rendezvousUrl = `https://${rendezvousUrl}`; + logger.info(`Resolved rendezvous URL to: ${rendezvousUrl}`); responseBody.rendezvous.url = rendezvousUrl; }); @@ -68,7 +70,7 @@ const startAPI = (orbit) => { }); app.listen(pinnerApiPort, () => { - logger.info(`Pinner API at http://localhost:${pinnerApiPort}`); + logger.info(`Pinner API at: http://localhost:${pinnerApiPort}`); }); setInterval(getStats, POLLING_INTERVAL, orbit); diff --git a/packages/concordia-pinner/src/utils/ipfsUtils.js b/packages/concordia-pinner/src/utils/ipfsUtils.js index f7386a6..876f9cc 100644 --- a/packages/concordia-pinner/src/utils/ipfsUtils.js +++ b/packages/concordia-pinner/src/utils/ipfsUtils.js @@ -27,18 +27,20 @@ const getRendezvousMultiaddress = () => { }; export const getResolvedRendezvousMultiaddress = async () => { - const rendezvousMultiaddress = getRendezvousMultiaddress(); + let rendezvousMultiaddress = getRendezvousMultiaddress(); const { address } = rendezvousMultiaddress.nodeAddress(); // Address is a domain to be resolved to IP if (rendezvousMultiaddress.toString().includes('/dns4/')) { try { + logger.info(`Multiaddress ${rendezvousMultiaddress.toString()} will be resolved.`); const resolvedDomain = await dnsLookup(address); - return Promise.resolve(new Multiaddr(`/ip4/${resolvedDomain.address}/tcp/${rendezvousPort}/wss/p2p-webrtc-star`)); + rendezvousMultiaddress = new Multiaddr(`/ip4/${resolvedDomain.address}/tcp/${rendezvousPort}/wss/p2p-webrtc-star`); } catch (error) { throw new Error(`DNS lookup of ${address} failed.\n${error}`); } } + logger.info(`Resolved rendezvous multiaddress is: ${rendezvousMultiaddress.toString()}`); return Promise.resolve(rendezvousMultiaddress); };