From 747bbced922fe0a806067069b072c9c61bc00fce Mon Sep 17 00:00:00 2001 From: HF Date: Mon, 12 Sep 2022 00:56:27 +0200 Subject: [PATCH] refactor whois --- src/core/isAllowed.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/isAllowed.js b/src/core/isAllowed.js index 29171a7..2a2532d 100644 --- a/src/core/isAllowed.js +++ b/src/core/isAllowed.js @@ -47,7 +47,6 @@ async function withoutCache(f, ip) { let allowed = true; let status = -2; let pcheck = null; - let whoisRet = null; try { if (await isWhitelisted(ipKey)) { @@ -64,8 +63,13 @@ async function withoutCache(f, ip) { allowed = res.allowed; pcheck = res.pcheck; } - whoisRet = await whois(ip); } finally { + let whoisRet = null; + try { + whoisRet = await whois(ip); + } catch (err) { + logger.error(`Error whois for ${ip}: ${err.message}`); + } await cacheAllowed(ipKey, status); await saveIPInfo(ipKey, whoisRet || {}, status, pcheck); }