Initial commit: Upload Checkpoint project

This commit is contained in:
Caileb 2025-05-26 22:25:42 -05:00
commit c0e3781244
32 changed files with 6121 additions and 0 deletions

13
utils/network.js Normal file
View file

@ -0,0 +1,13 @@
export function getRealIP(request, server) {
let ip = request.headers.get('x-forwarded-for') || request.headers.get('x-real-ip');
if (ip?.includes(',')) ip = ip.split(',')[0].trim();
if (!ip && server) {
ip = server.remoteAddress;
}
if (!ip) {
const url = new URL(request.url);
ip = url.hostname;
}
if (ip?.startsWith('::ffff:')) ip = ip.slice(7);
return ip;
}