add cookie. add city database
parent
5a8464e4e0
commit
63531f8753
|
@ -80,9 +80,9 @@ export async function getCountry(req, ip) {
|
||||||
return result?.country?.iso_code;
|
return result?.country?.iso_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getClientInfo(req, { screen, ip }) {
|
export async function getClientInfo(req, { screen }) {
|
||||||
const userAgent = req.headers['user-agent'];
|
const userAgent = req.headers['user-agent'];
|
||||||
// const ip = getIpAddress(req);
|
const ip = getIpAddress(req);
|
||||||
const country = await getCountry(req, ip);
|
const country = await getCountry(req, ip);
|
||||||
const browser = browserName(userAgent);
|
const browser = browserName(userAgent);
|
||||||
const os = detectOS(userAgent);
|
const os = detectOS(userAgent);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable no-console */
|
||||||
import { parseToken } from 'next-basics';
|
import { parseToken } from 'next-basics';
|
||||||
import { validate } from 'uuid';
|
import { validate } from 'uuid';
|
||||||
import { uuid } from 'lib/crypto';
|
import { uuid } from 'lib/crypto';
|
||||||
|
@ -45,8 +46,10 @@ export async function getSession(req) {
|
||||||
throw new Error(`Website not found: ${website_uuid}`);
|
throw new Error(`Website not found: ${website_uuid}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
// const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
||||||
const { userAgent, browser, os, country, device } = await getClientInfo(req, payload);
|
const { userAgent, browser, os, ip, country, device } = await getClientInfo(req, payload);
|
||||||
|
|
||||||
|
console.log('ip:', ip);
|
||||||
|
|
||||||
let session_uuid = uuid(websiteId, hostname, ip, userAgent);
|
let session_uuid = uuid(websiteId, hostname, ip, userAgent);
|
||||||
if (process.env.CROSSDOMAIN_TRACKING) {
|
if (process.env.CROSSDOMAIN_TRACKING) {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable no-console */
|
||||||
const { Resolver } = require('dns').promises;
|
const { Resolver } = require('dns').promises;
|
||||||
import isbot from 'isbot';
|
import isbot from 'isbot';
|
||||||
import ipaddr from 'ipaddr.js';
|
import ipaddr from 'ipaddr.js';
|
||||||
|
@ -38,6 +39,7 @@ export default async (req, res) => {
|
||||||
const clientIp = getIpAddress(req);
|
const clientIp = getIpAddress(req);
|
||||||
|
|
||||||
const blocked = ips.find(ip => {
|
const blocked = ips.find(ip => {
|
||||||
|
console.log('collect.js', ip, clientIp);
|
||||||
if (ip === clientIp) return true;
|
if (ip === clientIp) return true;
|
||||||
|
|
||||||
// CIDR notation
|
// CIDR notation
|
||||||
|
|
Loading…
Reference in New Issue