-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproxyprotocol.go
More file actions
36 lines (31 loc) · 909 Bytes
/
Copy pathproxyprotocol.go
File metadata and controls
36 lines (31 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Package proxyprotocol implement receiver for HA Proxy Protocol V1 and V2.
//
// Proxy Protocol spec http://www.haproxy.org/download/2.0/doc/proxy-protocol.txt
//
// This package provides a wrapper for the interface net.Listener, which extracts
// remote and local address of the connection from the headers in the format
// HA proxy protocol.
package proxyprotocol
import (
"bufio"
"errors"
"net"
)
// Header struct represent header parsing result
type Header struct {
SrcAddr net.Addr
DstAddr net.Addr
}
// HeaderParserBuilder build HeaderParser's
type HeaderParserBuilder interface {
Build(Logger) HeaderParser
}
// HeaderParser describe interface for header parsers
type HeaderParser interface {
Parse(readBuf *bufio.Reader) (*Header, error)
}
// Shared HeaderParser errors
var (
ErrInvalidSignature = errors.New("invalid signature")
ErrUnknownProtocol = errors.New("unknown protocol")
)