mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 23:57:12 +01:00
Load lookup database only once.
This commit is contained in:
parent
8307b46987
commit
0cf115b2de
1 changed files with 5 additions and 1 deletions
|
|
@ -12,6 +12,8 @@ import {
|
||||||
MOBILE_SCREEN_WIDTH,
|
MOBILE_SCREEN_WIDTH,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
|
|
||||||
|
let lookup;
|
||||||
|
|
||||||
export function getIpAddress(req) {
|
export function getIpAddress(req) {
|
||||||
// Cloudflare
|
// Cloudflare
|
||||||
if (req.headers['cf-connecting-ip']) {
|
if (req.headers['cf-connecting-ip']) {
|
||||||
|
|
@ -61,7 +63,9 @@ export async function getCountry(req, ip) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Database lookup
|
// 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);
|
const result = lookup.get(ip);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue