Merge branch 'dev' of https://github.com/umami-software/umami into dev
This commit is contained in:
+5
-3
@@ -77,8 +77,10 @@ function decodeHeader(s: string | undefined | null): string | undefined | null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getLocation(ip: string = '', headers: Headers, skipHeaders: boolean) {
|
export async function getLocation(ip: string = '', headers: Headers, skipHeaders: boolean) {
|
||||||
// Ignore local ips
|
const cleanIp = stripPort(ip);
|
||||||
if (!ip || (await isLocalhost(ip))) {
|
|
||||||
|
// Ignore local or invalid ips
|
||||||
|
if (!cleanIp || !ipaddr.isValid(cleanIp) || (await isLocalhost(cleanIp))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +110,7 @@ export async function getLocation(ip: string = '', headers: Headers, skipHeaders
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = globalThis[MAXMIND]?.get(stripPort(ip));
|
const result = globalThis[MAXMIND]?.get(cleanIp);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
const country = result.country?.iso_code ?? result?.registered_country?.iso_code;
|
const country = result.country?.iso_code ?? result?.registered_country?.iso_code;
|
||||||
|
|||||||
+1
-3
@@ -84,9 +84,7 @@ export function getIpAddress(headers: Headers) {
|
|||||||
if (header === 'forwarded') {
|
if (header === 'forwarded') {
|
||||||
const match = ip.match(/for=(\[?[0-9a-fA-F:.]+]?)/);
|
const match = ip.match(/for=(\[?[0-9a-fA-F:.]+]?)/);
|
||||||
|
|
||||||
if (match) {
|
return match ? resolveIp(match[1]) : undefined;
|
||||||
return resolveIp(match[1]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return resolveIp(ip);
|
return resolveIp(ip);
|
||||||
|
|||||||
Reference in New Issue
Block a user