Compare commits

..

1 Commits

Author SHA1 Message Date
a05656efff Documentation 2025-04-10 10:42:17 +02:00
3 changed files with 23 additions and 43 deletions

View File

@@ -2,10 +2,14 @@
# Install: # Install:
1. git clone it 1. git clone it
2. you need nodeJS / npm or bun 2. you need nodeJS / npm or [bun](https://bun.sh/docs/installation)
3. `npm install` or `bun i` 3. `npm install` or `bun i`
4. rename config.js.sample to config.js 4. rename config.js.sample to config.js
5. adjust config.js to your local MQTT-Broker 5. adjust config.js to your local MQTT-Broker
6. ` node ./mqtt.js` or `bun ./mqtt.js` 6. ` node ./mqtt.js` or `bun ./mqtt.js`
7. Point browser to localhost:8000 7. Point browser to localhost:8000
8. Enjoy streaming 8. Enjoy streaming
# Prequisites:
* MQTT Server (`apt install mosquitto` or docker-mosquitto)
* MQTT-Streaming at wavelog enabled (`config.php`-switch: `$config['mqtt_server']='your_mosquitto_server';`)

View File

@@ -1,8 +1,7 @@
const config = { const config = {
mqttserver: { mqttserver: {
host: "mqtt://[your mqtt-server here]" host: "mqtt://[your mqtt-server here]"
}, }
whitelist_url: "https://laber"
}; };
module.exports = config; module.exports = config;

27
mqtt.js
View File

@@ -7,7 +7,6 @@ const express = require('express');
const app = express(); // http-express framework laden (macht routing, etc.) const app = express(); // http-express framework laden (macht routing, etc.)
const http = require('http').Server(app); // http-server module laden const http = require('http').Server(app); // http-server module laden
const io = require('socket.io')(http); // socket.io einbinden const io = require('socket.io')(http); // socket.io einbinden
var whitelist=[];
app.use('/jquery', express.static(path.join(__dirname, 'node_modules', 'jquery', 'dist'))); app.use('/jquery', express.static(path.join(__dirname, 'node_modules', 'jquery', 'dist')));
@@ -41,7 +40,6 @@ mqttC.on('message', function (topic, message) { // Handler, wenn mqtt-message ko
} else { } else {
msg.content=message.toString(); // Ist nix json? dann ab in "content" damit msg.content=message.toString(); // Ist nix json? dann ab in "content" damit
} }
if (whitelist.whitelist.includes(msg.content.user_name)) {
if (topic.startsWith('wavelog/qso/logged')) { if (topic.startsWith('wavelog/qso/logged')) {
tobrowser=parse_qso_msg(msg.content); tobrowser=parse_qso_msg(msg.content);
if (tobrowser.qso_time) { if (tobrowser.qso_time) {
@@ -58,9 +56,6 @@ mqttC.on('message', function (topic, message) { // Handler, wenn mqtt-message ko
// io.emit("cat",tobrowser); // und raus an den Browser (nur fuer DIESES Socket, nicht fuer alle Clients) damit // io.emit("cat",tobrowser); // und raus an den Browser (nur fuer DIESES Socket, nicht fuer alle Clients) damit
console.log(topic+' / CAT for User '+tobrowser.user_id+' at '+tobrowser.qrg+' in Mode '+tobrowser.mode); console.log(topic+' / CAT for User '+tobrowser.user_id+' at '+tobrowser.qrg+' in Mode '+tobrowser.mode);
} }
} else {
console.log(msg.content.user_name+' not in Whitelist');
}
}); });
io.on('connection', (socket) => { // Neue socket.io Connection? io.on('connection', (socket) => { // Neue socket.io Connection?
@@ -80,19 +75,6 @@ function parse_cat_msg(topic,msg) {
return retmsg; return retmsg;
} }
async function getWhitelist() {
try {
const response = await fetch(config.whitelist_url);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();
whitelist = data;
} catch (error) {
console.error('Error fetching JSON data:', error);
}
}
function parse_qso_msg(msg) { function parse_qso_msg(msg) {
let retmsg={}; let retmsg={};
retmsg.call=msg.COL_CALL; retmsg.call=msg.COL_CALL;
@@ -112,11 +94,6 @@ const dinmin = (timestamp) => {
return Math.floor((Date.now() - new Date(timestamp).getTime()) / 60000); return Math.floor((Date.now() - new Date(timestamp).getTime()) / 60000);
} }
function startup() { http.listen(8000,'127.0.0.1', () => { // Webserver starten
getWhitelist();
http.listen(8000,'127.0.0.1', () => { // Webserver starten
console.log(`Socket.IO server running at http://localhost:8000/`); // debug console.log(`Socket.IO server running at http://localhost:8000/`); // debug
}); });
}
startup();