Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Merge branch 'analytics' of https://github.com/umami-software/umami into dev

Francis Cao1229663814c1
diff --cc src/lib/ip.ts
index a0e3a8252,f6ee733b9..a78c7e56e
--- a/src/lib/ip.ts
+++ b/src/lib/ip.ts
@@@ -1,6 -1,5 +1,7 @@@
+import ipaddr from 'ipaddr.js';
+
export const IP_ADDRESS_HEADERS = [
+ ...(process.env.CLOUD_MODE ? ['x-umami-client-ip'] : []), // Umami custom header (cloud mode only)
'true-client-ip', // CDN
'cf-connecting-ip', // Cloudflare
'fastly-client-ip', // Fastly
@@@ -81,10 -32,10 +82,10 @@@ export function getIpAddress(headers: H
}
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[1];
+ return resolveIp(match[1]);
}
}