Browse Source

fix: resolve rendezvous host only when docker prefix used

develop
Apostolos Fanakis 4 years ago
parent
commit
62d613d730
  1. 3
      packages/concordia-pinner/src/options/ipfsOptions.js
  2. 13
      packages/concordia-pinner/src/utils/ipfsUtils.js

3
packages/concordia-pinner/src/options/ipfsOptions.js

@ -7,8 +7,7 @@ const getIpfsOptions = async () => getSwarmAddresses()
.then((swarmAddresses) => { .then((swarmAddresses) => {
logger.info(`Swarm addresses used: ${swarmAddresses.join(', ')}`); logger.info(`Swarm addresses used: ${swarmAddresses.join(', ')}`);
return swarmAddresses; return swarmAddresses;
}) }).then((swarmAddresses) => {
.then((swarmAddresses) => {
const IPFS_DIRECTORY = process.env.IPFS_DIRECTORY || IPFS_DIRECTORY_DEFAULT; const IPFS_DIRECTORY = process.env.IPFS_DIRECTORY || IPFS_DIRECTORY_DEFAULT;
logger.info(`Setting up IPFS in repo: ${IPFS_DIRECTORY}`); logger.info(`Setting up IPFS in repo: ${IPFS_DIRECTORY}`);

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

@ -5,10 +5,17 @@ import { logger } from './logger';
const dnsLookup = util.promisify(dns.lookup); const dnsLookup = util.promisify(dns.lookup);
export const getResolvedRendezvousUrl = async () => dnsLookup(rendezvousHost, { family: 4 }) export const getResolvedRendezvousUrl = async () => {
if (rendezvousHost.startsWith('/docker/')) {
return dnsLookup(rendezvousHost.substring('/docker/'.length), { family: 4 })
.then((resolvedDomain) => `/ip4/${resolvedDomain.address}`)
.catch((error) => logger.error(new Error(`DNS lookup of ${rendezvousHost} failed.\n${error}`))); .catch((error) => logger.error(new Error(`DNS lookup of ${rendezvousHost} failed.\n${error}`)));
}
return Promise.resolve(rendezvousHost);
};
export const getSwarmAddresses = async () => getResolvedRendezvousUrl() export const getSwarmAddresses = async () => getResolvedRendezvousUrl()
.then((resolvedRendezvousUrl) => [ .then((resolvedRendezvousHost) => [
`${resolvedRendezvousUrl.address}/tcp/${rendezvousPort}/wss/p2p-webrtc-star`, `${resolvedRendezvousHost}/tcp/${rendezvousPort}/wss/p2p-webrtc-star`,
]); ]);

Loading…
Cancel
Save