Documentation
¶
Index ¶
- Variables
- type Conn
- func (c *Conn) Header() (Header, error)
- func (c *Conn) HeaderContext(ctx context.Context) (Header, error)
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) Read(b []byte) (n int, err error)
- func (c *Conn) ReadFrom(r io.Reader) (n int64, err error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) Write(b []byte) (n int, err error)
- func (c *Conn) WriteTo(w io.Writer) (n int64, err error)
- type Header
- type Listener
Constants ¶
This section is empty.
Variables ¶
var ( V1Identifier = []byte("PROXY ") V2Identifier = []byte("\r\n\r\n\x00\r\nQUIT\n") )
Functions ¶
This section is empty.
Types ¶
type Conn ¶
Conn wraps a net.Conn and provides access to the proxy protocol header. If the header is not present or cannot be read within the timeout, the connection is closed.
func (*Conn) RemoteAddr ¶
type Header ¶
type Header struct {
// Source is the ip address of the party that initiated the connection
Source net.Addr
// Destination is the ip address the remote party connected to; aka the address
// the proxy was listening for connections on.
Destination net.Addr
// True if the proxy header was UNKNOWN (v1) or if proto was set to LOCAL (v2)
// In which case Header.Source and Header.Destination will both be nil. TLVs still
// maybe available if v2, and Header.Unknown will be populated if v1.
IsLocal bool
// The version of the proxy protocol parsed
Version int
// The unparsed TLVs (Type-Length-Value) that were appended to the end of
// the v2 proto proxy header.
RawTLVs []byte
// Contains the complete header minus the cRLF if the proto was UNKNOWN
Unknown []byte
}
func ReadV2Header ¶
ReadV2Header assumes the first read will contain the identifier, then reads up until the length of the header as specified by the proxy protocol header. If you are using a bufio.Reader you can peek at the first 13 bytes to ensure the header identifier exists before passing the bufio.Reader to this function.