mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Added MQTT support over WSS and multiplexed with MPS
This commit is contained in:
parent
4094daf58f
commit
8f0517b80c
5 changed files with 134 additions and 0 deletions
54
mqttbroker.js
Normal file
54
mqttbroker.js
Normal file
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* @description MQTT broker reference implementation based on AEDES
|
||||
* @author Joko Banu Sastriawan
|
||||
* @copyright Intel Corporation 2018-2019
|
||||
* @license Apache-2.0
|
||||
* @version v0.0.1
|
||||
*/
|
||||
|
||||
|
||||
module.exports.CreateMQTTBroker = function (parent, db, args) {
|
||||
|
||||
// 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);
|
||||
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");
|
||||
callback(null);
|
||||
}
|
||||
|
||||
// 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");
|
||||
callback(null, sub);
|
||||
}
|
||||
|
||||
// check if a client can publish a packet
|
||||
obj.aedes.authorizeForward = function (client, packet) {
|
||||
//TODO: add forwarding control
|
||||
obj.parent.debug("mqtt","AuthorizeForward");
|
||||
return packet;
|
||||
}
|
||||
obj.handle = obj.aedes.handle;
|
||||
return obj;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue