Categorygithub.com/mastercactapus/proxyprotocol
modulepackage
0.0.4
Repository: https://github.com/mastercactapus/proxyprotocol.git
Documentation: pkg.go.dev

# README

proxyprotocol

GoDoc Build Status

This package provides PROXY protocol support for versions 1 and 2.

https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt

Features:

  • Auto detect both V1 and V2
  • Client & Server usage support
  • Listener with optional subnet filtering (for TCP/UDP listeners)

Installation

Installable via go get

go get -u github.com/mastercactapus/proxyprotocol

Usage

// Create any net.Listener
l, err := net.Listen("tcp", ":0")
l, err := net.Listen("udp", ":0")
l, err := net.Listen("unix", "/tmp/example")
l, err := net.Listen("unixgram", "/tmp/example")

// Wrap it to have RemoteAddr() and LocalAddr() resolved for all new connections
l = proxyprotocol.NewListener(l, 0)

c, err : = l.Accept()

c.RemoteAddr() // = The PROXY header source address
c.LocalAddr()  // = The PROXY header destination address

# Packages

No description provided by the author

# Functions

NewConn will wrap an existing net.Conn using `deadline` to receive the header.
NewListener will wrap nl, automatically handling PROXY headers for all connections.
Parse will parse detect and return a V1 or V2 header, otherwise InvalidHeaderErr is returned.

# Constants

CmdLocal indicates the connection was established on purpose by the proxy without being relayed.
CmdProxy the connection was established on behalf of another node, and reflects the original connection endpoints.

# Structs

Conn wraps a net.Conn using the PROXY protocol to determin LocalAddr() and RemoteAddr().
HeaderV1 contains information relayed by the PROXY protocol version 1 (human-readable) header.
HeaderV2 contains information relayed by the PROXY protocol version 2 (binary) header.
InvalidHeaderErr contains the parsing error as well as all data read from the reader.
Listener wraps a net.Listener automatically wrapping new connections with PROXY protocol support.
Rule contains configuration for a single subnet.

# Interfaces

Header provides information decoded from a PROXY header.

# Type aliases

Cmd indicates the PROXY command being used.