refactor whois
This commit is contained in:
parent
097926579f
commit
747bbced92
|
@ -47,7 +47,6 @@ async function withoutCache(f, ip) {
|
||||||
let allowed = true;
|
let allowed = true;
|
||||||
let status = -2;
|
let status = -2;
|
||||||
let pcheck = null;
|
let pcheck = null;
|
||||||
let whoisRet = null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (await isWhitelisted(ipKey)) {
|
if (await isWhitelisted(ipKey)) {
|
||||||
|
@ -64,8 +63,13 @@ async function withoutCache(f, ip) {
|
||||||
allowed = res.allowed;
|
allowed = res.allowed;
|
||||||
pcheck = res.pcheck;
|
pcheck = res.pcheck;
|
||||||
}
|
}
|
||||||
whoisRet = await whois(ip);
|
|
||||||
} finally {
|
} finally {
|
||||||
|
let whoisRet = null;
|
||||||
|
try {
|
||||||
|
whoisRet = await whois(ip);
|
||||||
|
} catch (err) {
|
||||||
|
logger.error(`Error whois for ${ip}: ${err.message}`);
|
||||||
|
}
|
||||||
await cacheAllowed(ipKey, status);
|
await cacheAllowed(ipKey, status);
|
||||||
await saveIPInfo(ipKey, whoisRet || {}, status, pcheck);
|
await saveIPInfo(ipKey, whoisRet || {}, status, pcheck);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user