INNER CODE UNIT · JavaScript
clientIp
bostrot/wsl2-distro-manager · n8n/licensing/seat_check.js:48
function clientIp(headers) {
const h = headers || {};
const forwarded = String(h['x-forwarded-for'] || '').split(',')[0].trim();
return String(h['cf-connecting-ip'] || h['x-real-ip'] || forwarded || 'unknown');
}
// Whatever the app sends, stored as at most 64 safe characters.
function normalizeDeviceId(value) {
if (typeof value !== 'string') return null;
const id = value.trim();
if (!id || id.length > 64 || !/^[A-Za-z0-9._:-]+$/.test(id)) return null;
return id;
}
function seatCount(row) {
const n = Math.floor(Number(row.seats));
return Number.isFinite(n) && n >= 1 ? n : 1;
}