diff --git a/public/index.html b/public/index.html index b432d54..5198370 100644 --- a/public/index.html +++ b/public/index.html @@ -5,7 +5,7 @@ Meshtastic MQTT Dashboard - + @@ -190,8 +190,8 @@ - - + + diff --git a/public/js/app.js b/public/js/app.js index e3fd69b..e2ccf6b 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -701,7 +701,7 @@ function displayNodes(nodes) {
${node.latitude && node.longitude ? ` - Location ${node.latitude.toFixed(6)}, ${node.longitude.toFixed(6)} - 🌍 @@ -948,7 +948,7 @@ function displayPositions(positions) { View Details - 🌍 diff --git a/src/config/config.js b/src/config/config.js index d6cf1d5..25bb65e 100644 --- a/src/config/config.js +++ b/src/config/config.js @@ -21,8 +21,8 @@ module.exports = { // MQTT configuration mqtt: { - broker: process.env.MQTT_BROKER || 'mqtt://mqtt.meshtastic.org', - port: parseInt(process.env.MQTT_PORT) || 1883, + broker: process.env.MQTT_BROKER || 'mqtts://mqtt.meshtastic.org:8883', + port: 8883, username: process.env.MQTT_USERNAME || 'meshdev', password: process.env.MQTT_PASSWORD || 'large4cats', topic: process.env.MQTT_TOPIC || 'msh/US/#', diff --git a/src/database/queries.js b/src/database/queries.js index 0f83768..a1fc155 100644 --- a/src/database/queries.js +++ b/src/database/queries.js @@ -27,7 +27,7 @@ const nodeQueries = { node_id, short_name, long_name, hardware_model, role, firmware_version, last_heard, battery_level, voltage, channel_utilization, air_util_tx, uptime_seconds, updated_at - ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP) + ) VALUES (?, ?, ?, ?, ?, ?, COALESCE(?, CURRENT_TIMESTAMP), ?, ?, ?, ?, ?, CURRENT_TIMESTAMP) ON CONFLICT(node_id) DO UPDATE SET short_name = COALESCE(excluded.short_name, short_name), long_name = COALESCE(excluded.long_name, long_name), @@ -72,24 +72,20 @@ const nodeQueries = { updateNullLastHeard: db.prepare(` UPDATE nodes - SET last_heard = ( - SELECT MAX(latest_time) - FROM ( - SELECT MAX(created_at) as latest_time FROM messages WHERE from_node = nodes.node_id - UNION ALL - SELECT MAX(timestamp) as latest_time FROM positions WHERE node_id = nodes.node_id - UNION ALL - SELECT MAX(timestamp) as latest_time FROM telemetry WHERE node_id = nodes.node_id - ) + SET last_heard = COALESCE( + ( + SELECT MAX(latest_time) + FROM ( + SELECT MAX(created_at) as latest_time FROM messages WHERE from_node = nodes.node_id + UNION ALL + SELECT MAX(timestamp) as latest_time FROM positions WHERE node_id = nodes.node_id + UNION ALL + SELECT MAX(timestamp) as latest_time FROM telemetry WHERE node_id = nodes.node_id + ) + ), + created_at ) WHERE last_heard IS NULL - AND EXISTS ( - SELECT 1 FROM messages WHERE from_node = nodes.node_id - UNION - SELECT 1 FROM positions WHERE node_id = nodes.node_id - UNION - SELECT 1 FROM telemetry WHERE node_id = nodes.node_id - ) `), getOldNodesWithData: db.prepare(` diff --git a/src/server.js b/src/server.js index 23374e7..011886e 100644 --- a/src/server.js +++ b/src/server.js @@ -19,12 +19,14 @@ app.use(helmet({ contentSecurityPolicy: { directives: { defaultSrc: ["'self'"], - styleSrc: ["'self'", "'unsafe-inline'", "https://unpkg.com"], - scriptSrc: ["'self'", "'unsafe-inline'", "https://unpkg.com"], + styleSrc: ["'self'", "'unsafe-inline'", "http://unpkg.com"], + scriptSrc: ["'self'", "'unsafe-inline'", "http://unpkg.com"], imgSrc: ["'self'", "data:", "https:", "http:"], - connectSrc: ["'self'"] + connectSrc: ["'self'"], + upgradeInsecureRequests: null } - } + }, + hsts: false })); // CORS configuration