mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
Sanitize IP to remove port for geolocation lookup
Sanitize IP address to remove port number before geolocation lookup. This ensures proper MaxMind database resolution in setups where IP:PORT is passed by the proxy.
This commit is contained in:
parent
0c2070771b
commit
26ddfd5a80
1 changed files with 3 additions and 1 deletions
|
|
@ -127,7 +127,9 @@ export async function getLocation(ip: string = '', headers: Headers, hasPayloadI
|
|||
global[MAXMIND] = await maxmind.open(path.resolve(dir, 'GeoLite2-City.mmdb'));
|
||||
}
|
||||
|
||||
const result = global[MAXMIND].get(ip);
|
||||
// When the client IP is extracted from headers, sometimes the value includes a port
|
||||
const cleanIp = ip?.split(':')[0];
|
||||
const result = global[MAXMIND].get(cleanIp);
|
||||
|
||||
if (result) {
|
||||
const country = result.country?.iso_code ?? result?.registered_country?.iso_code;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue