Switch MQTT to TLS, fix last_heard fallback, downgrade CDN to HTTP

This commit is contained in:
Will Bradley
2026-04-14 09:08:49 -07:00
parent 74f41c5044
commit 150c61fe65
5 changed files with 27 additions and 29 deletions
+2 -2
View File
@@ -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/#',
+13 -17
View File
@@ -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(`
+6 -4
View File
@@ -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