Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aedes-protocol-decoder

Package Overview
Dependencies
Maintainers
1
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

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2K
decreased by-0.16%
Maintainers
1
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 decodeProtocol hook, which is called when aedes instance receives a first valid buffer 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 trustProxy option is set to true, it will first parse http headers (x-real-ip | x-forwarded-for) and proxy protocol (v1 and v2) to retrieve information in client.connDetails.

The function protocolDecoder 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 net = require('net')
var port = 1883

var broker = aedes({
	decodeProtocol: function (client, buffer) {
	  var proto = protocolDecoder(client, buffer)
	  return proto
	},
	preConnect: function (client, done) {
	  if (client.connDetails && client.connDetails.ipAddress) {
	    client.ip = client.connDetails.ipAddress
	  }
	  return done(null, true)
	},
	trustProxy: true
})

var server = net.createServer(broker.handle)

server.listen(port, function () {
  console.log('server listening on port', port)
})


License

MIT

Keywords

FAQs

Package last updated on 04 Feb 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc