add broker

This commit is contained in:
Litlyx
2024-05-31 14:08:51 +02:00
parent 2b185a9db5
commit 9caec3b92b
17 changed files with 489415 additions and 0 deletions

15
broker/src/utils/Utils.ts Normal file
View File

@@ -0,0 +1,15 @@
import { Request } from "express";
import crypto from 'crypto';
export function getIPFromRequest(req: Request) {
const ip = req.header('X-Real-IP') || req.header('X-Forwarded-For') || '0.0.0.0';
return ip;
}
export function createSessionHash(website: string, ip: string, userAgent: string) {
const dailySalt = new Date().toLocaleDateString('it-IT');
const sessionClean = dailySalt + website + ip + userAgent;
const sessionHash = crypto.createHash('md5').update(sessionClean).digest("hex");
return sessionHash;
}