Fix jwt-token
This commit is contained in:
@@ -423,11 +423,7 @@ const MapView = () => {
|
|||||||
// Calculate values first
|
// Calculate values first
|
||||||
const totalDrones = detections.length;
|
const totalDrones = detections.length;
|
||||||
|
|
||||||
const opacity = getDetectionOpacity(detection);
|
// Define helper functions first before using them
|
||||||
const age = getDetectionAge(detection);
|
|
||||||
console.log('MapView: Detection age:', age, 'opacity:', opacity);
|
|
||||||
|
|
||||||
// Calculate ring radius based on RSSI (rough distance estimation)
|
|
||||||
const getRssiRadius = (rssi) => {
|
const getRssiRadius = (rssi) => {
|
||||||
if (rssi > -40) return 100; // <100m - very close
|
if (rssi > -40) return 100; // <100m - very close
|
||||||
if (rssi > -60) return 500; // ~500m - close
|
if (rssi > -60) return 500; // ~500m - close
|
||||||
@@ -437,10 +433,6 @@ const MapView = () => {
|
|||||||
return 15000; // ~15km - maximum range
|
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) => {
|
const getRingColor = (rssi, droneType, droneIndex, totalDrones) => {
|
||||||
// Orlan drones (type 1) always red
|
// Orlan drones (type 1) always red
|
||||||
if (droneType === 1) return '#dc2626'; // red-600
|
if (droneType === 1) return '#dc2626'; // red-600
|
||||||
@@ -466,9 +458,6 @@ const MapView = () => {
|
|||||||
return '#16a34a'; // green-600 - far
|
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) => {
|
const getDashPattern = (droneType, droneIndex, totalDrones) => {
|
||||||
if (droneType === 1) return null; // Orlan always solid
|
if (droneType === 1) return null; // Orlan always solid
|
||||||
|
|
||||||
@@ -485,7 +474,6 @@ const MapView = () => {
|
|||||||
return patterns[droneIndex % patterns.length];
|
return patterns[droneIndex % patterns.length];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Slight offset for multiple rings to make them more visible
|
|
||||||
const getPositionOffset = (droneIndex, totalDrones) => {
|
const getPositionOffset = (droneIndex, totalDrones) => {
|
||||||
if (totalDrones === 1) return [0, 0];
|
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 dashPattern = getDashPattern(detection.drone_type, droneIndex, totalDrones);
|
||||||
const [latOffset, lonOffset] = getPositionOffset(droneIndex, totalDrones);
|
const [latOffset, lonOffset] = getPositionOffset(droneIndex, totalDrones);
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ const errorHandler = require('./middleware/errorHandler');
|
|||||||
const { apiDebugMiddleware } = require('./utils/apiDebugLogger');
|
const { apiDebugMiddleware } = require('./utils/apiDebugLogger');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
// Trust proxy headers for getting real client IPs behind nginx
|
||||||
|
app.set('trust proxy', true);
|
||||||
|
|
||||||
const server = createServer(app);
|
const server = createServer(app);
|
||||||
const io = new Server(server, {
|
const io = new Server(server, {
|
||||||
cors: {
|
cors: {
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
function initializeSocketHandlers(io) {
|
function initializeSocketHandlers(io) {
|
||||||
io.on('connection', (socket) => {
|
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}`);
|
console.log(`Client connected: ${socket.id} from IP: ${clientIP}`);
|
||||||
|
|
||||||
// Join device-specific rooms for targeted updates
|
// Join device-specific rooms for targeted updates
|
||||||
|
|||||||
Reference in New Issue
Block a user