Compare commits
2 Commits
c60764fa66
...
d5de48350c
| Author | SHA1 | Date | |
|---|---|---|---|
| d5de48350c | |||
| 21af41467e |
@@ -2,7 +2,8 @@ const config = {
|
|||||||
mqttserver: {
|
mqttserver: {
|
||||||
host: "mqtt://[your mqtt-server here]"
|
host: "mqtt://[your mqtt-server here]"
|
||||||
},
|
},
|
||||||
whitelist_url: "https://laber"
|
whitelist_url: "https://laber",
|
||||||
|
whitelist_enabled: false
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = config;
|
module.exports = config;
|
||||||
|
|||||||
21
mqtt.js
21
mqtt.js
@@ -41,7 +41,7 @@ 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 (!(config.whitelist_enabled) || (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) {
|
||||||
@@ -81,15 +81,17 @@ function parse_cat_msg(topic,msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getWhitelist() {
|
async function getWhitelist() {
|
||||||
try {
|
if (config.whitelist_enabled) {
|
||||||
const response = await fetch(config.whitelist_url);
|
try {
|
||||||
if (!response.ok) {
|
const response = await fetch(config.whitelist_url);
|
||||||
throw new Error(`HTTP error! Status: ${response.status}`);
|
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);
|
||||||
}
|
}
|
||||||
const data = await response.json();
|
|
||||||
whitelist = data;
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching JSON data:', error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +119,7 @@ function startup() {
|
|||||||
http.listen(8000,'127.0.0.1', () => { // Webserver starten
|
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
|
||||||
});
|
});
|
||||||
|
const intervalID = setInterval(getWhitelist,5*60*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
startup();
|
startup();
|
||||||
|
|||||||
Reference in New Issue
Block a user