mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 01:21:20 -04:00
no more ips in session data
This commit is contained in:
@@ -22,33 +22,10 @@ logger.info('Discord invite loaded:', discordInvite ? 'present' : 'not configure
|
||||
logger.info('Ko-fi link loaded:', kofiLink ? 'present' : 'not configured');
|
||||
|
||||
const ACTIVITY_SYNC_COOLDOWN_MS = 3000;
|
||||
const ADMIN_ROLES = new Set(['admin', 'lockdown', 'lockdown-admin']);
|
||||
let lastActivitySync = 0;
|
||||
let pendingActivitySync = null;
|
||||
|
||||
function extractSocketIp(socket) {
|
||||
if (!socket) return null;
|
||||
const headers = socket.handshake?.headers || {};
|
||||
const forwardedFor = headers['x-forwarded-for'];
|
||||
if (typeof forwardedFor === 'string' && forwardedFor.trim()) {
|
||||
return forwardedFor.split(',')[0].trim();
|
||||
}
|
||||
if (Array.isArray(forwardedFor) && forwardedFor.length) {
|
||||
return String(forwardedFor[0]).trim();
|
||||
}
|
||||
const realIp = headers['x-real-ip'];
|
||||
if (typeof realIp === 'string' && realIp.trim()) {
|
||||
return realIp.trim();
|
||||
}
|
||||
return (
|
||||
socket.handshake?.address ||
|
||||
socket.conn?.remoteAddress ||
|
||||
socket.request?.connection?.remoteAddress ||
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
function buildUserEntry(socket, includeIp = false) {
|
||||
function buildUserEntry(socket) {
|
||||
if (!socket) return null;
|
||||
const role = getRole(socket);
|
||||
const assignment = assignmentService.describeAssignment(socket.id);
|
||||
@@ -58,14 +35,12 @@ function buildUserEntry(socket, includeIp = false) {
|
||||
nickname: getNickname(socket) || null,
|
||||
role,
|
||||
roverId: primaryRover || assignment?.roverId || null,
|
||||
ip: includeIp ? extractSocketIp(socket) : null,
|
||||
};
|
||||
}
|
||||
|
||||
function buildSession(socket) {
|
||||
const includeIps = ADMIN_ROLES.has(getRole(socket));
|
||||
const users = Array.from(io.sockets.sockets.values())
|
||||
.map((sock) => buildUserEntry(sock, includeIps))
|
||||
.map((sock) => buildUserEntry(sock))
|
||||
.filter(Boolean);
|
||||
return {
|
||||
socketId: socket?.id || null,
|
||||
|
||||
@@ -17,16 +17,6 @@ export default function AdminPanel() {
|
||||
const currentGoal = session?.communityGoal?.text || '';
|
||||
const goalUpdatedAt = session?.communityGoal?.updatedAt || null;
|
||||
const [goalDraft, setGoalDraft] = useState(currentGoal);
|
||||
const socketIps = useMemo(() => {
|
||||
const users = session?.users ?? [];
|
||||
return users
|
||||
.map((user) => ({
|
||||
socketId: user.socketId,
|
||||
label: user.nickname || user.socketId?.slice(0, 6) || 'unknown',
|
||||
ip: user.ip || null,
|
||||
}))
|
||||
.filter((entry) => entry.ip);
|
||||
}, [session?.users]);
|
||||
|
||||
const isAdmin =
|
||||
session?.role === 'admin' ||
|
||||
@@ -145,7 +135,6 @@ export default function AdminPanel() {
|
||||
)}
|
||||
/>
|
||||
<ReplaySnapshotHealth health={health} />
|
||||
<WebsocketIpPanel entries={socketIps} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -211,30 +200,3 @@ function ReplaySnapshotHealth({ health }) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function WebsocketIpPanel({ entries }) {
|
||||
const total = entries?.length || 0;
|
||||
const uniqueCount = useMemo(() => new Set((entries || []).map((entry) => entry.ip)).size, [entries]);
|
||||
return (
|
||||
<div className="space-y-0.5">
|
||||
<div className="flex items-center justify-between text-xs text-slate-400">
|
||||
<span className="panel-muted text-xs uppercase">Websocket IPs</span>
|
||||
<span className="text-slate-500">
|
||||
{uniqueCount} unique / {total} sockets
|
||||
</span>
|
||||
</div>
|
||||
<div className="surface space-y-0.5 text-xs text-slate-200">
|
||||
{total === 0 ? (
|
||||
<p className="text-xs text-slate-500">No IPs reported yet.</p>
|
||||
) : (
|
||||
entries.map((entry) => (
|
||||
<div key={entry.socketId} className="flex items-center justify-between">
|
||||
<span className="text-slate-300">{entry.label}</span>
|
||||
<span className="rounded bg-slate-800 px-1 text-[0.7rem] text-slate-200">{entry.ip}</span>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user