proxyprotocol

package
v3.0.0-...-1f68d82 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package proxyprotocol partially implements PROXY protocol proposed by HAProxy, aiming at high-performance integration with the rest of ZBProxy. The full protocol specification can be found at https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt

Index

Constants

View Source
const (
	VersionUnspecified = iota
	Version1
	Version2
)
View Source
const (
	CommandLocal = 0x0
	CommandProxy = 0x1

	TransportProtocolIPv4     = 0x10
	TransportProtocolIPv6     = 0x20
	TransportProtocolUnix     = 0x30
	TransportProtocolStream   = 0x1
	TransportProtocolDatagram = 0x2
)

Variables

View Source
var (
	ErrNotProxyProtocol = errors.New("not PROXY protocol")
)

Functions

func AddressFamilyByAddr

func AddressFamilyByAddr(addr netip.Addr) uint8

func HandleConnection

func HandleConnection(conn *bufio.CachedConn, metadata *adapter.Metadata) (bool, error)

HandleConnection reads PROXY protocol header from the connection, returning whether the source address is changed and the error (if present).

func TransportProtocolByNetwork

func TransportProtocolByNetwork(network string) uint8

Types

type Header struct {
	Version           uint8
	Command           uint8
	TransportProtocol uint8
	SourceAddress     netip.AddrPort
}

func ReadHeader

func ReadHeader(conn *bufio.CachedConn) (*Header, error)

func (*Header) WriteHeader

func (h *Header) WriteHeader(w io.Writer, destination netip.AddrPort) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL