mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-07 21:13:44 +02:00
Cache null results from Maxmind.
This commit is contained in:
parent
f558b088e6
commit
7b1c0c4013
1 changed files with 4 additions and 6 deletions
|
@ -32,21 +32,19 @@ function lookup(ip,callback)
|
||||||
if (cachedEntry) {
|
if (cachedEntry) {
|
||||||
let ts = cachedEntry.ts;
|
let ts = cachedEntry.ts;
|
||||||
let r = cachedEntry.r;
|
let r = cachedEntry.r;
|
||||||
if ((ts)&&(r)) {
|
if (ts) {
|
||||||
if ((Date.now() - ts) < CACHE_TTL) {
|
if ((Date.now() - ts) < CACHE_TTL)
|
||||||
r._cached = true;
|
|
||||||
return callback(null,r);
|
return callback(null,r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
geo(ip,function(err,result) {
|
geo(ip,function(err,result) {
|
||||||
if (err)
|
if (err)
|
||||||
return callback(err,null);
|
return callback(err,null);
|
||||||
if ((!result)||(!result.location))
|
if (!result)
|
||||||
return callback(new Error('null result'),null);
|
result = null;
|
||||||
|
|
||||||
cache.put(ip,JSON.stringify({
|
cache.put(ip,JSON.stringify({
|
||||||
ts: Date.now(),
|
ts: Date.now(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue