mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-30 16:57:44 +01:00
Added IP address ignore list.
This commit is contained in:
parent
34098bd0b4
commit
fc22f5969c
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "umami",
|
"name": "umami",
|
||||||
"version": "0.74.0",
|
"version": "0.75.0",
|
||||||
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
||||||
"author": "Mike Cao <mike@mikecao.com>",
|
"author": "Mike Cao <mike@mikecao.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -3,12 +3,22 @@ import { savePageView, saveEvent } from 'lib/queries';
|
|||||||
import { useCors, useSession } from 'lib/middleware';
|
import { useCors, useSession } from 'lib/middleware';
|
||||||
import { ok, badRequest } from 'lib/response';
|
import { ok, badRequest } from 'lib/response';
|
||||||
import { createToken } from 'lib/crypto';
|
import { createToken } from 'lib/crypto';
|
||||||
|
import { getIpAddress } from '../../lib/request';
|
||||||
|
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
if (isBot(req.headers['user-agent'])) {
|
if (isBot(req.headers['user-agent'])) {
|
||||||
return ok(res);
|
return ok(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.env.IGNORE_IP) {
|
||||||
|
const ips = process.env.IGNORE_IP.split(',').map(n => n.trim());
|
||||||
|
const ip = getIpAddress(req);
|
||||||
|
|
||||||
|
if (ips.includes(ip)) {
|
||||||
|
return ok(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await useCors(req, res);
|
await useCors(req, res);
|
||||||
await useSession(req, res);
|
await useSession(req, res);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user