Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@balena/proxy-protocol-v2
Advanced tools
Encoder and Decoder for proxy protocol
A simple encoder and decoder for proxy protocol headers using the v1 text and v2 binary formats.
See http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt for details.
Supports IPv4 and IPv6, UDP and TCP, but not UNIX sockets.
npm install proxy-protocol-v2
Separate v1 and v2 encoders are provided.
var buf = require('proxy-protocol-v2').v2_encode(socket);
or
var buf = require('proxy-protocol-v2').v2_encode({
remoteFamily: 'IPv4',
remoteAddress: '12.34.56.78',
remotePort: 1234,
localAddress: '172.16.0.1,
localPort: 8080,
protocol: 'udp'
});
protocol
defaults to 'tcp'
if unspecified.
The v1_encode
function has the same API but is constrained by the limits of the v1 format, so only the tcp
protocol is supported.
A generic decoder is provided that detects the format of any header. If no valid v1 or v2 signature is detected, null
is returned.
var details = require('proxy-protocol-v2').decode(buf);
if(details === null) {
console.log('No proxy protocol header detected');
}
var remoteFamily = details.remoteFamily,
remoteAddress = details.remoteAddress,
remotePort = details.remotePort,
localAddress = details.localAddress,
localPort = details.localPort,
protocol = details.prototol;
Separate decoders are provided for each version if the expected version is known.
var v1_details = require('proxy-protocol-v2').v1_decode(buf);
var v2_details = require('proxy-protocol-v2').v2_decode(buf);
The format-specific functions will assume the presence of a header and may throw an Error or return invalid details if a header is not present.
Each decode operation takes an optional validate
second argument which causes the header to be validated (with an Error being thrown if invalid) at the minor cost of checking the signature validity an other validity checks on field values.
nodeunit test
FAQs
Encoder and Decoder for proxy protocol
The npm package @balena/proxy-protocol-v2 receives a total of 0 weekly downloads. As such, @balena/proxy-protocol-v2 popularity was classified as not popular.
We found that @balena/proxy-protocol-v2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.