Browse Source

fix: pinner logging

develop
Ezerous 3 years ago
parent
commit
464b9ae05f
  1. 8
      packages/concordia-pinner/src/app.js
  2. 6
      packages/concordia-pinner/src/utils/ipfsUtils.js

8
packages/concordia-pinner/src/app.js

@ -22,8 +22,10 @@ const responseBody = {
getResolvedRendezvousMultiaddress().then((multiaddress) => { getResolvedRendezvousMultiaddress().then((multiaddress) => {
const { address, port } = multiaddress.nodeAddress(); const { address, port } = multiaddress.nodeAddress();
const rendezvousUrl = `http://${address}:${port}`; let rendezvousUrl = `${address}:${port}`;
logger.info(`Resolved rendezvous URL to ${rendezvousUrl}`); if (port !== 443) rendezvousUrl = `http://${rendezvousUrl}`;
else rendezvousUrl = `https://${rendezvousUrl}`;
logger.info(`Resolved rendezvous URL to: ${rendezvousUrl}`);
responseBody.rendezvous.url = rendezvousUrl; responseBody.rendezvous.url = rendezvousUrl;
}); });
@ -68,7 +70,7 @@ const startAPI = (orbit) => {
}); });
app.listen(pinnerApiPort, () => { app.listen(pinnerApiPort, () => {
logger.info(`Pinner API at http://localhost:${pinnerApiPort}`); logger.info(`Pinner API at: http://localhost:${pinnerApiPort}`);
}); });
setInterval(getStats, POLLING_INTERVAL, orbit); setInterval(getStats, POLLING_INTERVAL, orbit);

6
packages/concordia-pinner/src/utils/ipfsUtils.js

@ -27,18 +27,20 @@ const getRendezvousMultiaddress = () => {
}; };
export const getResolvedRendezvousMultiaddress = async () => { export const getResolvedRendezvousMultiaddress = async () => {
const rendezvousMultiaddress = getRendezvousMultiaddress(); let rendezvousMultiaddress = getRendezvousMultiaddress();
const { address } = rendezvousMultiaddress.nodeAddress(); const { address } = rendezvousMultiaddress.nodeAddress();
// Address is a domain to be resolved to IP // Address is a domain to be resolved to IP
if (rendezvousMultiaddress.toString().includes('/dns4/')) { if (rendezvousMultiaddress.toString().includes('/dns4/')) {
try { try {
logger.info(`Multiaddress ${rendezvousMultiaddress.toString()} will be resolved.`);
const resolvedDomain = await dnsLookup(address); 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) { } catch (error) {
throw new Error(`DNS lookup of ${address} failed.\n${error}`); throw new Error(`DNS lookup of ${address} failed.\n${error}`);
} }
} }
logger.info(`Resolved rendezvous multiaddress is: ${rendezvousMultiaddress.toString()}`);
return Promise.resolve(rendezvousMultiaddress); return Promise.resolve(rendezvousMultiaddress);
}; };

Loading…
Cancel
Save