1
0
mirror of https://github.com/mikecao/umami.git synced 2021-05-17 18:46:32 +03:00

Load lookup database only once.

This commit is contained in:
Mike Cao
2021-04-25 18:32:06 -07:00
parent 8307b46987
commit 0cf115b2de

View File

@@ -12,6 +12,8 @@ import {
MOBILE_SCREEN_WIDTH,
} from './constants';
let lookup;
export function getIpAddress(req) {
// Cloudflare
if (req.headers['cf-connecting-ip']) {
@@ -61,7 +63,9 @@ export async function getCountry(req, ip) {
}
// Database lookup
const lookup = await maxmind.open(path.resolve('./public/geo/GeoLite2-Country.mmdb'));
if (!lookup) {
lookup = await maxmind.open(path.resolve('./public/geo/GeoLite2-Country.mmdb'));
}
const result = lookup.get(ip);