mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Made MQTT optional.
This commit is contained in:
parent
40c896c766
commit
893fea2329
7 changed files with 88 additions and 86 deletions
|
@ -6,49 +6,46 @@
|
|||
* @version v0.0.1
|
||||
*/
|
||||
|
||||
|
||||
module.exports.CreateMQTTBroker = function (parent, db, args) {
|
||||
|
||||
// internal objects container
|
||||
|
||||
// Internal objects container
|
||||
var obj = {}
|
||||
obj.parent = parent;
|
||||
obj.db = db;
|
||||
obj.args = args;
|
||||
|
||||
obj.aedes = require("aedes")();
|
||||
|
||||
|
||||
|
||||
// argument parsing -- tbd
|
||||
|
||||
|
||||
// event handling and filtering
|
||||
// authentication filter
|
||||
obj.aedes.authenticate = function (client, username, password, callback) {
|
||||
// accept all user
|
||||
// TODO: add authentication handler
|
||||
obj.parent.debug("mqtt","Authentication with "+username+":"+password);
|
||||
obj.parent.debug("mqtt", "Authentication with " + username + ":" + password);
|
||||
callback(null, true);
|
||||
}
|
||||
|
||||
|
||||
// check if a client can publish a packet
|
||||
obj.aedes.authorizePublish = function (client, packet, callback) {
|
||||
//TODO: add authorized publish control
|
||||
obj.parent.debug("mqtt","AuthorizePublish");
|
||||
// TODO: add authorized publish control
|
||||
obj.parent.debug("mqtt", "AuthorizePublish");
|
||||
callback(null);
|
||||
}
|
||||
|
||||
// check if a client can publish a packet
|
||||
|
||||
// Check if a client can publish a packet
|
||||
obj.aedes.authorizeSubscribe = function (client, sub, callback) {
|
||||
//TODO: add subscription control here
|
||||
obj.parent.debug("mqtt","AuthorizeSubscribe");
|
||||
// TODO: add subscription control here
|
||||
obj.parent.debug("mqtt", "AuthorizeSubscribe");
|
||||
callback(null, sub);
|
||||
}
|
||||
|
||||
// check if a client can publish a packet
|
||||
|
||||
// Check if a client can publish a packet
|
||||
obj.aedes.authorizeForward = function (client, packet) {
|
||||
//TODO: add forwarding control
|
||||
obj.parent.debug("mqtt","AuthorizeForward");
|
||||
// TODO: add forwarding control
|
||||
obj.parent.debug("mqtt", "AuthorizeForward");
|
||||
return packet;
|
||||
}
|
||||
obj.handle = obj.aedes.handle;
|
||||
return obj;
|
||||
|
||||
obj.handle = obj.aedes.handle;
|
||||
return obj;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue