|
@ -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 () => { |
|
|
.catch((error) => logger.error(new Error(`DNS lookup of ${rendezvousHost} failed.\n${error}`))); |
|
|
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}`))); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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`, |
|
|
]); |
|
|
]); |
|
|