const isTargetReachable = async target => { const url = new URL(prependHttp(target)); if (!url.port) { url.port = url.protocol === 'http:' ? 80 : 443; } let address; try { address = await getAddress(url.hostname); } catch (_) { return false; } if (!address || routerIps.has(address)) { return false; } if ([80, 443].includes(url.port)) { return checkHttp(url.toString()); } return isPortReachable(url.port, {host: address}); }