šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

aedes-protocol-decoder

Package Overview
Dependencies
Maintainers
4
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aedes-protocol-decoder

Aedes plugin to decode connection frame and validate proxies

2.2.0
latest
Source
npm
Version published
Weekly downloads
2.3K
-16.62%
Maintainers
4
Weekly downloads
Ā 
Created
Source

aedes-protocol-decoder

Dependencies Status devDependencies Status
Known Vulnerabilities Coverage Status NPM version NPM downloads

js-standard-style

Protocol decoder for Aedes MQTT Broker

The purpose of this module is to be used inside aedes-server-factory bindConnection function, which is called when the server receives a connection from client (before CONNECT packet). The client object state is in default and its connected state is false. The function extract socket details and if aedes-server-factory trustProxy option is set to true, it will first parse http headers (x-real-ip | x-forwarded-for) and/or proxy protocol (v1 and v2), then passing the informations to aedes that will assign them to client.connDetails.

Additionally, if the current socket is a TLS socket, the module will extract the authorization status and the full certificate chain.

The function protocolDecoder and extractSocketDetails returns ConnectionDetails, if the object contains data property, it will be parsed as an mqtt-packet.

Install

npm install aedes-protocol-decoder --save

Example

var aedes = require('aedes')
var { protocolDecoder } = require('aedes-protocol-decoder')
var { createServer } = require('aedes-server-factory')
var port = 1883

var broker = aedes({
	preConnect: function (client, packet, done) {
	  if (client.connDetails && client.connDetails.ipAddress) {
	    client.ip = client.connDetails.ipAddress
	  }
	  return done(null, true)
	},
})

var server = createServer(broker, { trustProxy: true, protocolDecoder })
server.listen(port, function () {
  console.log('server listening on port', port)
})

License

MIT

Keywords

mqtt

FAQs

Package last updated on 20 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts