{"id":13583602,"url":"https://github.com/ably/proxy-protocol-v2","last_synced_at":"2025-04-06T21:32:32.437Z","repository":{"id":33765040,"uuid":"37420728","full_name":"ably/proxy-protocol-v2","owner":"ably","description":"A simple encoder and decoder for the proxy protocol v2 binary format","archived":true,"fork":false,"pushed_at":"2021-09-20T12:11:12.000Z","size":8,"stargazers_count":19,"open_issues_count":0,"forks_count":8,"subscribers_count":30,"default_branch":"main","last_synced_at":"2024-08-02T15:53:34.788Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ably.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-14T16:47:20.000Z","updated_at":"2024-01-22T17:41:32.000Z","dependencies_parsed_at":"2022-08-02T15:15:14.022Z","dependency_job_id":null,"html_url":"https://github.com/ably/proxy-protocol-v2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ably%2Fproxy-protocol-v2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ably%2Fproxy-protocol-v2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ably%2Fproxy-protocol-v2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ably%2Fproxy-protocol-v2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ably","download_url":"https://codeload.github.com/ably/proxy-protocol-v2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223264878,"owners_count":17116229,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T15:03:37.567Z","updated_at":"2024-11-06T00:30:28.987Z","avatar_url":"https://github.com/ably.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# proxy-protocol-v2\n\n## Overview\n\nA simple encoder and decoder for proxy protocol headers using the v1 text and v2 binary formats.\n\nSee http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt for details.\n\nSupports IPv4 and IPv6, UDP and TCP, but not UNIX sockets.\n\n## install\n\n    npm install proxy-protocol-v2\n\n## encode\n\nSeparate v1 and v2 encoders are provided.\n\n````\nvar buf = require('proxy-protocol-v2').v2_encode(socket);\n````\n\nor\n\n````\nvar buf = require('proxy-protocol-v2').v2_encode({\n  remoteFamily: 'IPv4',\n  remoteAddress: '12.34.56.78',\n  remotePort: 1234,\n  localAddress: '172.16.0.1,\n  localPort: 8080,\n  protocol: 'udp'\n});\n````\n\n`protocol` defaults to `'tcp'` if unspecified.\n\nThe `v1_encode` function has the same API but is constrained by the limits of the v1 format, so only the `tcp` protocol is supported.\n\n## decode\n\nA generic decoder is provided that detects the format of any header. If no valid v1 or v2 signature is detected, `null` is returned.\n\n````\nvar details = require('proxy-protocol-v2').decode(buf);\nif(details === null) {\n    console.log('No proxy protocol header detected');\n}\n\nvar remoteFamily = details.remoteFamily,\n    remoteAddress = details.remoteAddress,\n    remotePort = details.remotePort,\n    localAddress = details.localAddress,\n    localPort = details.localPort,\n    protocol = details.prototol;\n````\n\nSeparate decoders are provided for each version if the expected version is known.\n\n````\nvar v1_details = require('proxy-protocol-v2').v1_decode(buf);\nvar v2_details = require('proxy-protocol-v2').v2_decode(buf);\n````\n\nThe 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.\n\nEach 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.\n\n## test\n\n    nodeunit test","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fably%2Fproxy-protocol-v2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fably%2Fproxy-protocol-v2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fably%2Fproxy-protocol-v2/lists"}