Fix jwt-token

This commit is contained in:
2025-09-10 13:32:25 +02:00
parent 7dc4d41a47
commit df77d6d744
3 changed files with 20 additions and 14 deletions

View File

@@ -423,11 +423,7 @@ const MapView = () => {
// Calculate values first
const totalDrones = detections.length;
const opacity = getDetectionOpacity(detection);
const age = getDetectionAge(detection);
console.log('MapView: Detection age:', age, 'opacity:', opacity);
// Calculate ring radius based on RSSI (rough distance estimation)
// Define helper functions first before using them
const getRssiRadius = (rssi) => {
if (rssi > -40) return 100; // <100m - very close
if (rssi > -60) return 500; // ~500m - close
@@ -437,10 +433,6 @@ const MapView = () => {
return 15000; // ~15km - maximum range
};
const radius = getRssiRadius(detection.rssi);
console.log('MapView: Ring radius:', radius, 'for RSSI:', detection.rssi);
// Color based on threat level and multiple drone differentiation
const getRingColor = (rssi, droneType, droneIndex, totalDrones) => {
// Orlan drones (type 1) always red
if (droneType === 1) return '#dc2626'; // red-600
@@ -466,9 +458,6 @@ const MapView = () => {
return '#16a34a'; // green-600 - far
};
const ringColor = getRingColor(detection.rssi, detection.drone_type, droneIndex, totalDrones);
// Different visual styles for multiple drones at same detector
const getDashPattern = (droneType, droneIndex, totalDrones) => {
if (droneType === 1) return null; // Orlan always solid
@@ -485,7 +474,6 @@ const MapView = () => {
return patterns[droneIndex % patterns.length];
};
// Slight offset for multiple rings to make them more visible
const getPositionOffset = (droneIndex, totalDrones) => {
if (totalDrones === 1) return [0, 0];
@@ -497,6 +485,15 @@ const MapView = () => {
];
};
// Now calculate values using the functions
const opacity = getDetectionOpacity(detection);
const age = getDetectionAge(detection);
console.log('MapView: Detection age:', age, 'opacity:', opacity);
const radius = getRssiRadius(detection.rssi);
console.log('MapView: Ring radius:', radius, 'for RSSI:', detection.rssi);
const ringColor = getRingColor(detection.rssi, detection.drone_type, droneIndex, totalDrones);
const dashPattern = getDashPattern(detection.drone_type, droneIndex, totalDrones);
const [latOffset, lonOffset] = getPositionOffset(droneIndex, totalDrones);

View File

@@ -19,6 +19,10 @@ const errorHandler = require('./middleware/errorHandler');
const { apiDebugMiddleware } = require('./utils/apiDebugLogger');
const app = express();
// Trust proxy headers for getting real client IPs behind nginx
app.set('trust proxy', true);
const server = createServer(app);
const io = new Server(server, {
cors: {

View File

@@ -1,6 +1,11 @@
function initializeSocketHandlers(io) {
io.on('connection', (socket) => {
const clientIP = socket.handshake.address || socket.request.connection.remoteAddress || 'unknown';
// Get real client IP from proxy headers (nginx forwarded headers)
const clientIP = socket.handshake.headers['x-forwarded-for']?.split(',')[0]?.trim() ||
socket.handshake.headers['x-real-ip'] ||
socket.handshake.address ||
socket.request.connection.remoteAddress ||
'unknown';
console.log(`Client connected: ${socket.id} from IP: ${clientIP}`);
// Join device-specific rooms for targeted updates