Skip to content

InkerBot/proxyprotocol

 
 

Repository files navigation

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

About

Client & server PROXY protocol support in Go.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%