mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: ensure check returns false if no addresses are looked up, fix bug where cached value got changed accidentally
This commit is contained in:
@@ -45,7 +45,8 @@ async function init() {
|
|||||||
* - For whatever reason `undici` needs to be required so that lookup can be overwritten properly.
|
* - For whatever reason `undici` needs to be required so that lookup can be overwritten properly.
|
||||||
*/
|
*/
|
||||||
function lookup(hostname, options, callback) {
|
function lookup(hostname, options, callback) {
|
||||||
const { ok, lookup } = checkCache.get(hostname);
|
let { ok, lookup } = checkCache.get(hostname);
|
||||||
|
lookup = [...lookup];
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
throw new Error('lookup-failed');
|
throw new Error('lookup-failed');
|
||||||
}
|
}
|
||||||
@@ -166,6 +167,10 @@ async function check(url) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (addresses.size < 1) {
|
||||||
|
return { ok: false };
|
||||||
|
}
|
||||||
|
|
||||||
// Every IP address that the host resolves to should be a unicast address
|
// Every IP address that the host resolves to should be a unicast address
|
||||||
const ok = Array.from(addresses).every(({ address: ip }) => {
|
const ok = Array.from(addresses).every(({ address: ip }) => {
|
||||||
const parsed = ipaddr.parse(ip);
|
const parsed = ipaddr.parse(ip);
|
||||||
|
|||||||
Reference in New Issue
Block a user